<?php
$suggested = $this->session->userdata('suggested');
//echo $suggested;
//exit();
$printed = array(FALSE);
$sdata['suggested'] = $suggested;
foreach ($suggested_person as $v_suggested_person) {
    if (!$printed[$v_suggested_person->person_id]) {
        if (strstr($suggested, $v_suggested_person->person_id . ',')) {
            continue;
        }
        $sdata['suggested'] .= $v_suggested_person->person_id . ',';
        $printed[$v_suggested_person->person_id] = TRUE;
        $image = $person_info[$v_suggested_person->person_id]->person_image_thumb;
        $name = $person_info[$v_suggested_person->person_id]->person_first_name . ' ' . $person_info[$v_suggested_person->person_id]->person_last_name;

        if ($linked_person[$v_suggested_person->person_id]) {
//            $i++;
            $status = $linked_person[$v_suggested_person->person_id]->add_link_request_status;
            $requested_person_id = $linked_person[$v_suggested_person->person_id]->requested_person_id;

            if ($status != 1) {
                if ($status == 2 || ($status == 3 && $requested_person_id != $this->session->userdata('user_id')) || $status == 0 || ($status == 5 && $requested_person_id != $this->session->userdata('user_id'))) {
                    ?>
                    <!--<div class="col-sm-6 form-group" id="<?php // echo 'sActions' . $v_suggested_person->person_id                 ?>">-->
                    <input type="hidden" id="pID" value="<?php echo $v_suggested_person->person_id; ?>">
                    <div class="col-sm-12  white link-height padding-zero" style="height: 170px">
                        <span class="col-sm-12 text-right padding-zero ">

                            <?php if ($status == 3) {
                                ?>
                                <a href="javascript:void(0)"
                                   onclick="return checkForLinkAction('<?php echo base_url() . 'accept-suggested-link/' . $v_suggested_person->person_id; ?>', 'Accept Request', ' Do you want to Accept Request', '<?php echo $v_suggested_person->person_id; ?>')">
                                    <i class="fa fa-check-circle" title="Accept Request"></i>
                                </a>&nbsp;&nbsp;

                                <a href="javascript:void(0)"
                                   onclick="return blockPerson('<?php echo base_url() . 'block-connectivity-suggested-person/' . $v_suggested_person->person_id; ?>', 'Block Person', ' Do you want to Block Person', '<?php echo $v_suggested_person->person_id; ?>')"> 
                                    <i class="fa fa-ban" title="Block Person"></i>
                                </a>&nbsp;&nbsp;

                                <a href="javascript:void(0)"
                                   onclick="return checkForLinkAction('<?php echo base_url() . 'cancel-suggested-link/' . $v_suggested_person->person_id; ?>', 'Calcel Request', ' Do you want to Cancel Request', '<?php echo $v_suggested_person->person_id; ?>')">
                                    <i class="fa fa-user-times" title="Cancel Request"></i>
                                </a>&nbsp;&nbsp;


                            <?php } else if ($status == 2 || $status == 0 || $status == 5) {
                                ?>
                                <!--send request-->

                                <a href="javascript:void(0)" 
                                   onclick="connectUser('<?php echo base_url() . $v_suggested_person->person_id . '/connect-connectivity-suggested-user'; ?>', '<?php echo $v_suggested_person->person_id; ?>')">
                                    <i class="fa fa-chain" title="Connect"></i>
                                </a>&nbsp;&nbsp;&nbsp;

                                <a href="javascript:void(0)"
                                   onclick="return blockPerson('<?php echo base_url() . 'block-connectivity-suggested-person/' . $v_suggested_person->person_id; ?>', 'Block Person', ' Do you want to Block Person', '<?php echo $v_suggested_person->person_id; ?>')"> 
                                    <i class="fa fa-ban" title="Block Person"></i>
                                </a>&nbsp;&nbsp;
                            <?php } ?>

                            <a href="javascript:void(0)"
                               onclick="return blockPerson('<?php echo base_url() . 'block-connectivity-suggested-person/' . $v_suggested_person->person_id; ?>', 'Block Person', ' Do you want to Block Person', '<?php echo $v_suggested_person->person_id; ?>')"> 
                                <i class="fa fa-ban" title="Block Person"></i>
                            </a>&nbsp;&nbsp;

                            <a href="javascript:;" 
                               onclick="nextPerson('<?php echo base_url() . 'next-connectivity-suggested-person'; ?>', '<?php echo $v_suggested_person->person_id; ?>')">
                                <i class="fa fa-times"></i>
                            </a>
                        </span>
                        <div class="col-sm-4 padding-zero">
                            <a href="<?php echo base_url() . $person_info[$v_suggested_person->person_id]->url . '/profile'; ?>">
                                <?php if ($image) { ?>

                                    <img src="<?php echo base_url() . $image; ?>" 
                                         class="img-responsive image-thum" alt="logo">

                                <?php } else { ?>

                                    <img src="<?php echo base_url() . 'image/no_profile_picture.png'; ?>" 
                                         class="img-responsive image-thum" alt="logo">

                                <?php } ?>
                            </a>
                        </div>
                        <div class="col-sm-8 padding-zero text-left">
                            <address class="margin-zero">
                                <div class="col-sm-12">
                                    <?php
                                    if ($person_work_experience[$v_suggested_person->person_id]) {
                                        echo $person_work_experience[$v_suggested_person->person_id]->designation;
                                    } else if ($person_education[$v_suggested_person->person_id]) {
                                        echo 'Student';
                                    }
                                    ?>
                                </div>
                                <div class="col-sm-12">
                                    <?php
                                    if ($person_work_experience[$v_suggested_person->person_id]) {
                                        echo $person_work_experience[$v_suggested_person->person_id]->company_name;
                                    } else if ($person_education[$v_suggested_person->person_id]) {
                                        echo $person_education[$v_suggested_person->person_id]->education_institute_name;
                                    }
                                    ?>
                                </div>
                            </address>
                        </div>
                        <div class="col-sm-12 padding-zero text-left">

                            <div class="col-sm-12">
                                <a href="<?php echo base_url() . $person_info[$v_suggested_person->person_id]->url . '/profile'; ?>">
                                    <?php echo $name; ?>
                                </a>
                            </div>

                        </div>

                    </div>
                    <!--</div>-->
                    <?php
                }
            }
        } else {
            ?>
            <input type="hidden" id="pID" value="<?php echo $v_suggested_person->person_id; ?>">
            <div class="col-sm-12  white link-height padding-zero" style="height: 170px">
                <span class="col-sm-12 text-right padding-zero ">
                    <a href="javascript:void(0)" 
                       onclick="connectUser('<?php echo base_url() . $v_suggested_person->person_id . '/connect-connectivity-suggested-user'; ?>', '<?php echo $v_suggested_person->person_id; ?>')">
                        <i class="fa fa-chain" title="Connect"></i>
                    </a> &nbsp;&nbsp;

                    <a href="javascript:void(0)"
                       onclick="return blockPerson('<?php echo base_url() . 'block-connectivity-suggested-person/' . $v_suggested_person->person_id; ?>', 'Block Person', ' Do you want to Block Person', '<?php echo $v_suggested_person->person_id; ?>')"> 
                        <i class="fa fa-ban" title="Block Person"></i>
                    </a>&nbsp;&nbsp;

                    <a href="javascript:;" 
                       onclick="nextPerson('<?php echo base_url() . 'next-connectivity-suggested-person'; ?>', '<?php echo $v_suggested_person->person_id; ?>')">
                        <i class="fa fa-times"></i>
                    </a>&nbsp;&nbsp;&nbsp;
                </span>
                <div class="col-sm-4 padding-zero">
                    <a href="<?php echo base_url() . $person_info[$v_suggested_person->person_id]->url . '/profile'; ?>">
                        <?php if ($person_info[$v_suggested_person->person_id]->person_image_thumb) { ?>
                            <img src="<?php echo base_url() . 'content-library/' . $person_info[$v_suggested_person->person_id]->url . '/' . $person_info[$v_suggested_person->person_id]->person_image_thumb; ?>" 
                                 class="img-responsive image-thum" alt="logo">
                        <?php } else { ?>
                            <img src="<?php echo base_url() . 'image/no_profile_picture.png'; ?>" 
                                 class="img-responsive image-thum" alt="logo">
                             <?php } ?>
                    </a>
                </div>
                <div class="col-sm-8 padding-zero text-left">
                    <address class="margin-zero">
                        <div class="col-sm-12">
                            <?php
                            if ($person_work_experience[$v_suggested_person->person_id]) {
                                echo $person_work_experience[$v_suggested_person->person_id]->designation;
                            } else if ($person_education[$v_suggested_person->person_id]) {
                                echo 'Student';
                            }
                            ?>
                        </div>
                        <div class="col-sm-12">
                            <?php
                            if ($person_work_experience[$v_suggested_person->person_id]) {
                                echo $person_work_experience[$v_suggested_person->person_id]->company_name;
                            } else if ($person_education[$v_suggested_person->person_id]) {
                                echo $person_education[$v_suggested_person->person_id]->education_institute_name;
                            }
                            ?>
                        </div>
                    </address>
                </div>
                <div class="col-sm-12 padding-zero text-left">

                    <div class="col-sm-12">
                        <a href="<?php echo base_url() . $person_info[$v_suggested_person->person_id]->url . '/profile'; ?>">
                            <?php echo $name; ?>
                        </a>
                    </div>

                </div>
            </div>
            <!--</div>-->

            <?php
        }
    }
    $this->session->set_userdata($sdata);
    break;
}
?>