<?php
$user_id = $this->session->userdata('user_id');
?>


<section class="course">    
    <div class="container-fluid">
        <div class="col-sm-12">
            <div class="col-sm-8 " >
                <div class="row ">
                    <div class="col-sm-12 gray_ttc" style="padding: 0">
                        <div class="col-sm-3" style="padding: 5px">
                            <a href="<?php echo base_url() . $person_info->url . '/profile' ?>">    
                                <?php if ($person_info->person_image) { ?>
                                    <div><img src="<?php echo base_url() . 'content-library/' . $person_info->url . '/' . $person_info->person_image; ?>" style="width: 200px;height: 230px" class="img-responsive"></div>
                                <?php } else { ?>
                                    <div><img src="<?php echo base_url() ?>image/no_profile_picture.png" class="img-responsive" style="width: 230px;height: 230px"></div>
                                <?php } ?>
                            </a>
                        </div>
                        <div class="col-sm-9" style="padding-left: 40px">
                            <div class="col-sm-12" style="padding: 0">
                                <div class="col-sm-12" style="padding: 0">
                                    <h1>
                                        <span class="pull-left">
                                            <a href="javascript:void(0)">
                                                <?php echo $person_info->person_first_name . ' ' . $person_info->person_last_name ?>   
                                            </a>
                                        </span>
                                    </h1>

                                </div>

                                <div class="col-sm-12"><br></div>
                                <div class="col-sm-12" style="padding: 0">
                                    <h5>
                                        <span class="pull-left" style="padding:0 10px 10px 0">
                                            <p><span id="view_country"></span>  
                                                <?php
                                                if ($user_work_details) {
                                                    echo '| <a href="#">';
                                                    foreach ($user_work_details as $v_user_work_details) {
                                                        $current_status = $v_user_work_details->work_details_status;
                                                        if ($current_status == 1) {
                                                            echo $v_user_work_details->company_name;
                                                            break;
                                                        } else {
                                                            echo '';
                                                        }
                                                    }
                                                    echo ' </a>';
                                                }
                                                ?>
                                            </p>
                                        </span>
                                        <script>
                                            var country = getCountryName('<?php echo $person_info->person_country; ?>');
                                            document.getElementById('view_country').innerHTML = country;
                                        </script>
                                    </h5>
                                </div>

                                <div class="col-sm-12" style="padding: 0">
                                    <h5>
                                        <span class="pull-left">
                                            <?php
                                            if ($user_work_details) {
                                                echo '<a href="#" style="margin-right: 32px">Current</a>  <a href="#">';
                                                foreach ($user_work_details as $v_user_work_details) {
                                                    $current_status = $v_user_work_details->work_details_status;
                                                    if ($current_status == 1) {
                                                        echo $v_user_work_details->company_name;
                                                        break;
                                                    } else {
                                                        echo '';
                                                    }
                                                }
                                                echo '</a>';
                                            }
                                            ?>
                                        </span>
                                    </h5>
                                </div>

                                <div class="col-sm-12" style="padding: 0">
                                    <h5>
                                        <span class="pull-left">
                                            <?php
                                            if ($user_education_details) {
                                                echo ' <a href="#" style="margin-right: 20px">Education</a> 
                                                <a href="#">';
                                                foreach ($user_education_details as $v_user_education_details) {
                                                    echo $v_user_education_details->education_institute_name;
                                                    break;
                                                }
                                                echo ' </a>';
                                            }
                                            ?>
                                        </span>
                                    </h5>
                                </div>




                                <div class="col-sm-12"><br><br></div>
                                <div class="col-sm-12" style="padding: 0">
                                    <?php if ($person_info->person_id != $this->session->userdata('user_id')) { ?>
                                        <div class="col-sm-4">
                                            <a href="<?php echo base_url() . $person_info->person_id . '/sign-in-and-connect'; ?>" id="connectButton"  class="green-btn btn btn-default">Connect</a><br/><br/>
                                            <script>
                                                connectLink = "<?php echo base_url() . $person_info->person_id . '/sign-in-and-connect'; ?>";
                                            </script>
                                        </div>
                                        <div class="col-sm-4">
                                            <input type="button" class="green-btn btn btn-default" value="Send Message"><br/><br/>
                                        </div>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    </div>


                    <div class="col-sm-12 text-left" style="padding: 10px;background-color: #F0F0F0" >
                        <div class="col-sm-1"> 
                            <span><img src="<?php echo base_url() ?>image/logo.png" style="width: 20px" class="img-responsive" alt="logo"></span>
                        </div>
                        <div class="col-sm-11" style="padding: 0;">
                            <span><a href="<?php echo base_url() . $person_info->url ?>"><?php echo base_url() . $person_info->url ?> </a></span>
                        </div>
                    </div>


                </div>
                <div class="col-sm-12"><br></div>

                <div class="row ">
                    <div class="col-sm-12 white" style="padding: 0">
                        <div class="col-sm-12 text-left" style="padding: 10px 0 0 20px">
                            <span><i class="fa fa-file-text fa-2x">&nbsp;&nbsp;&nbsp;</i>Experience</span>

                        </div>
                        <div class="col-sm-12 text-left gray" style="padding: 5px 0 0 20px">
                            <?php
                            foreach ($user_work_details as $v_user_work_details) {
                                if ($v_user_work_details->person_work_view_status == 1) {
                                    ?>
                                    <div class="col-sm-12">
                                        <h3><a href="#"><?php echo $v_user_work_details->designation ?></a></h3>
                                        <span><?php echo $v_user_work_details->company_name ?></span><br>
                                        <span><?php echo date('F Y', strtotime($v_user_work_details->job_start_date)) ?> -
                                            <?php
                                            $current_status = $v_user_work_details->work_currently_here;
                                            if ($current_status == 1) {
                                                echo ' At Present Time';
                                            } else {
                                                echo date('F Y', strtotime($v_user_work_details->job_end_date));
                                            }
                                            ?> 
                                            | <?php echo $v_user_work_details->company_address ?> </span><br><br>

                                        <p class="text-justify"> 
                                            <?php echo $v_user_work_details->job_responsibility_details ?>
                                        </p>
                                    </div>
                                    <?php
                                }
                            }
                            ?>
                        </div>

                    </div>

                    <div class="col-sm-12"><br></div>
                    <?php
                    if ($person_info->person_role == 2) {
                        
                    } else if ($person_info->person_role != 5) {
                        ?>
                        <div class="col-sm-12 white" style="padding: 0">
                            <div class="col-sm-12 text-left" style="padding: 5px 0 0 20px">
                                <span><i class="fa fa-book fa-2x">&nbsp;&nbsp;&nbsp;</i>Course</span>
                            </div>

                            <div class="col-sm-12 text-left gray" style="padding: 5px 0 0 20px">
                                <?php
                                if (!$person_course_info) {
                                    if ($user_id == $person_info->person_id) {
                                        ?>
                                        <h3>You did not create any course <a href="<?php echo base_url() . 'create-course' ?>">Create Course</a></h3>
                                        <?php
                                    }
                                } else {
                                    ?>
                                    <h3><a href="#">Created By <?php echo $person_info->person_first_name . ' ' . $person_info->person_last_name; ?>  </a></h3>
                                    <?php
                                }
                                if ($person_course_info) {
                                    foreach ($person_course_info as $v_person_course_info) {
                                        ?>
                                        <p class="text-justify"><i class="fa fa-book">&nbsp;&nbsp;</i> 


                                            <?php echo $v_person_course_info->course_name; ?>

                                        </p>

                                        <?php
                                    }
                                }
                                if (isset($person_course_with_organization_info)) {
                                    ?>
                                    <h3><a href="#">Created By <?php echo $organization_name; ?>  </a></h3>  
                                    <?php
                                    foreach ($person_course_with_organization_info as $v_person_course_info) {
                                        ?>
                                        <p class="text-justify"><i class="fa fa-book">&nbsp;&nbsp;</i> 


                                            <?php echo $v_person_course_info->course_name; ?>

                                        </p>

                                        <?php
                                    }
                                    ?>
                                <?php }
                                ?>

                            </div>
                        </div>
                    <?php } else { ?>
                        <div class="col-sm-12 white" style="padding: 0">
                            <div class="col-sm-12 text-left" style="padding: 5px 0 0 20px">
                                <span><i class="fa fa-book fa-2x">&nbsp;&nbsp;&nbsp;</i>Course</span>
                            </div>

                            <div class="col-sm-12 text-left gray" style="padding: 5px 0 0 20px">
                                <?php foreach ($person_organization_name as $o_value) { ?>
                                    <h3><a href=""><?php echo $o_value->organization_name; ?></a></h3>
                                    <?php foreach ($person_orgaanization_course_name[$o_value->organization_id] as $c_value) {
                                        ?>
                                        <p class="text-justify"><i class="fa fa-book">&nbsp;&nbsp;</i><?php echo $c_value->course_name; ?></p>
                                        <?php
                                    }
                                }
                                ?>
                            </div>
                        </div>
                    <?php } ?>
                    <div class="col-sm-12"><br></div>
                    <div class="col-sm-12 white" style="padding: 0">
                        <div class="col-sm-12 text-left" style="padding: 5px 0 0 20px">
                            <span><i class="fa fa-globe fa-2x">&nbsp;&nbsp;&nbsp;</i>Language</span>
                        </div>
                        <div class="col-sm-12 text-left gray" >
                            <?php foreach ($person_language as $l_value) { ?>

                                <div class="col-sm-6 text-left" style="padding: 5px 0 0 20px">
                                    <h3><?php echo $l_value->person_language; ?></h3>
                                    <p><?php
                                        switch ($l_value->person_language_proficiency) {
                                            case 0:
                                                echo 'No Proficiency';
                                                break;
                                            case 1:
                                                echo 'Elementary Proficiency';
                                                break;
                                            case 2:
                                                echo 'Limited Working Proficiency';
                                                break;
                                            case 3:
                                                echo 'Professional Working Proficiency';
                                                break;
                                            case 4:
                                                echo 'Full Professional Proficiency';
                                                break;
                                            case 5:
                                                echo 'Native or Bilingual Proficiency';
                                                break;
                                        }
                                        ?></p>
                                </div>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="col-sm-12"><br></div>

                    <div class="col-sm-12 white" style="padding: 0">
                        <div class="col-sm-12 text-left" style="padding: 5px 0 0 20px">
                            <span><i class="fa fa-bar-chart-o fa-2x">&nbsp;&nbsp;&nbsp;</i>Skills</span>
                        </div>

                        <div class="col-sm-12 text-left gray" style="padding-left: 20px">

                            <h3><a href="#">Top Skills</a></h3>


                            <table class="table table-striped table-hover col-sm-12 table-responsive">
                                <thead>
                                    <tr>
                                        <th>Name</th>
                                        <th>Mark</th>
                                        <th>Time to Complete</th>
                                        <th>Actions</th>
                                    </tr>
                                </thead>
                                <tbody>

                                    <?php
                                    if ($all_quiz) {
                                        foreach ($all_quiz as $v_quiz) {
                                            $quiz_id = $v_quiz->quiz_id;
                                            $quiz_status = $v_quiz->quiz_status;
                                            $url = $v_quiz->url;
                                            $quiz_pulication_status = $v_quiz->quiz_pulication_status;
                                            ?>

                                            <tr class="gray">
                                                <td><?php echo $v_quiz->quiz_name; ?></td>
                                                <td>
                                                    <?php echo $quiz_result[$v_quiz->quiz_id]->quiz_total_marks; ?> &nbsp; 

                                                    <?php
                                                    if ($rank[$v_quiz->quiz_id] <= 5) {
                                                        echo "<button class='btn btn-success'>  Top " . 5 . "</button>";
                                                    } else if ($rank[$v_quiz->quiz_id] <= 10) {
                                                        echo "<button class='btn btn-success'>  Top " . 10 . "</button>";
                                                    } else if ($rank[$v_quiz->quiz_id] <= 25) {
                                                        echo "<button class='btn btn-success'>  Top " . 25 . "</button>";
                                                    }
                                                    ?> 
                                                </td>
                                                <?php
                                                $quiz_total_time = 0;
                                                foreach ($quiz_questions[$v_quiz->quiz_id] as $value) {
                                                    $quiz_total_time += $value->time_limit;
                                                }
                                                ?>
                                                <td>
                                                    <?php
                                                    echo $this->cf->sec2view($quiz_result[$v_quiz->quiz_id]->quiz_finish_time) . ' / ' . $this->cf->sec2view($quiz_total_time * 60);
                                                    ?>
                                                </td>
                                                <td>
                                                    <a href="<?php echo base_url() . $person_info->url . '/' . $v_quiz->url . '/skill-details'; ?>"><div class="span1"><i class="fa fa-zoom-in" title="Edit">Details</i></div></a>
                                                </td>
                                            </tr>
                                            <?php
                                        }
                                    }
                                    ?>

                                </tbody>
                            </table>


                        </div>

                        <div class="col-sm-12 text-left white" style="padding-left: 20px">
                            <h3><a href="#">Self Assessment Skills</a></h3>
                            <?php
                            foreach ($person_self_assessmet_skills as $s_value) {
                                echo '<span class="btn btn-success" style="margin-left: 5px; margin-bottom: 10px">' . $s_value->self_assessment_skills_name . '</span>';
                            }
                            ?>
                        </div>
                    </div>


                    <div class="col-sm-12 " ><br></div>
                    <div class="col-sm-12 white" style="padding: 0">
                        <div class="col-sm-12 text-left gray" style="padding: 5px 0 0 20px">

                            <?php
                            foreach ($user_education_details as $v_user_education_details) {
                                if ($v_user_education_details->person_education_view_status) {
                                    ?>

                                    <div class="col-sm-12">
                                        <h3><a href="javasscript:void(0)"><?php echo $v_user_education_details->education_institute_name; ?></a></h3>
                                        <span><?php echo $v_user_education_details->educational_description; ?></span><br>
                                        <span><?php echo date('Y', strtotime($v_user_education_details->start_time_period)) ?> – <?php echo date('Y', strtotime($v_user_education_details->end_time_period)) ?></span>

                                    </div>

                                <?php }
                            }
                            ?>
                        </div>
                    </div>
                    <div class="col-sm-12"><br></div>
                    <div class="col-sm-12 white" style="padding: 0">
                        <div class="col-sm-12 text-left" style="padding: 5px 0 0 20px">
                            <span><i class="fa fa-refresh fa-2x">&nbsp;&nbsp;&nbsp;</i>Additional Info</span>
                        </div>

                        <div class="col-sm-12 text-left gray" style="padding: 5px 0 0 20px">
                            <h3><a href="#">Interests </a></h3>
                            <span><?php
                                foreach ($interest_field_info_all as $v_interest_field_info_all) {
                                    if ($v_interest_field_info_all) {
                                        echo '<span class="btn btn-success" style="margin-left: 5px; margin-bottom: 10px">' . $v_interest_field_info_all->field_of_interest_name . '</span>';
                                    }
                                }
                                ?>
                            </span><br></br>

                        </div>

                        <div class="col-sm-12 text-left white" style="padding: 20px">
                            <h3><a href="#">Personal Details</a></h3><br>

                            <?php
                            if ($person_info->person_join_tt) {
                                ?>
                                <span class="col-sm-8"> 
                                    <span class="col-sm-6">Join Talha Corporation</span>
                                    <span class="col-sm-6"><?php echo date('d F Y', strtotime($person_info->person_join_tt)); ?></span> 
                                </span>
                                <?php
                            }
                            if ($person_info->person_email_view_status == 1) {
                                ?>
                                <span class="col-sm-12"><br></span>
                                <span class="col-sm-8"> 
                                    <span class="col-sm-6">Email Address</span>
                                    <span class="col-sm-6"><?php echo $person_info->person_email ?></span>
                                </span>
                                <?php
                            }
                            if ($person_info->person_contact_number) {
                                if ($person_info->person_contact_number_view_status == 1) {
                                    ?>
                                    <span class="col-sm-12"><br></span>
                                    <span class="col-sm-8"> 
                                        <span class="col-sm-6">Contact Number</span>
                                        <span class="col-sm-6"><?php echo $person_info->person_contact_number ?></span>
                                    </span>
                                    <?php
                                }
                            }
                            ?>

                            <?php
                            if ($person_info->person_country) {
                                ?>
                                <span class="col-sm-12"><br></span>
                                <span class="col-sm-8"> 
                                    <span class="col-sm-6">Country</span>
                                    <span class="col-sm-6" id="view_country1"></span>
                                </span>
                                <script>
                                    var country = getCountryName('<?php echo $person_info->person_country ?>');
                                    document.getElementById('view_country1').innerHTML = country;
                                </script>
                            <?php } ?>

                            <?php
                            if ($person_info->person_city) {
                                ?>
                                <span class="col-sm-12"><br></span>
                                <span class="col-sm-8"> 
                                    <span class="col-sm-6">City</span>
                                    <span class="col-sm-6"><?php echo $person_info->person_city ?></span>
                                </span>
                            <?php } ?>

                            <?php
                            if ($person_info->person_address) {
                                if ($person_info->person_address_view_status == 1) {
                                    ?>
                                    <span class="col-sm-12"><br></span>
                                    <span class="col-sm-8"> 
                                        <span class="col-sm-6">Address</span>
                                        <span class="col-sm-6"><?php echo $person_info->person_address ?></span>
                                    </span>
                                    <?php
                                }
                            }
                            ?>

                            <?php
                            if ($person_info->person_gender) {
                                ?>
                                <span class="col-sm-12"><br></span>
                                <span class="col-sm-8"> 
                                    <span class="col-sm-6">Gender</span>
                                    <span class="col-sm-6">
                                        <?php
                                        $gender = $person_info->person_gender;
                                        if ($gender == 1) {
                                            echo 'Male';
                                        } else if ($gender == 2) {
                                            echo 'Female';
                                        } else {
                                            echo 'Other';
                                        }
                                        ?></span>
                                </span>
                            <?php } ?>

                            <?php
                            if ($person_info->person_birthday) {
                                if ($person_info->person_birthday_view_status == 1) {
                                    ?>
                                    <span class="col-sm-12"><br></span>
                                    <span class="col-sm-8"> 
                                        <span class="col-sm-6">Birthday</span>
                                        <span class="col-sm-6"><?php echo $person_info->person_birthday ?></span>
                                    </span>
                                    <?php
                                }
                            }
                            ?>

                            <span class="col-sm-12"><br></span>
                            <span class="col-sm-8"> 
                                <span class="col-sm-6">Link</span>
                                <span class="col-sm-6"><?php echo $total_friends; ?></span>
                            </span>

                        </div>
                    </div>
                    <div class="col-sm-12"><br></div>

                </div>


            </div>
<?php //echo $right_content; ?>
        </div>
    </div>
</section>

