<?php
echo ' <div id="view_without_paginzation" style=" opacity: 0.3">';
$person_id = $this->session->userdata('person_id');
$person_role = $this->session->userdata('person_role');
$i = 0;
foreach ($all_course as $course_value) {
    ++$i;
    ?>
    <div class="<?php
    if ($i % 2 == 0) {
        echo 'row white';
    } else {
        echo 'row gray';
    }
    ?>">
        <div class="col-sm-6 form-group" style="text-align: left !important">
            <a href="<?php echo base_url() . $course_value->url; ?>" id="courseNameView<?php echo $course_value->url ?>" target="_blank" class="red">
                <?php
                if (strlen($course_value->course_name) < 41) {
                    echo $course_value->course_name;
                } else {
                    echo character_limiter($course_value->course_name, 40);
                }
                echo '</a>';
                if (strlen($course_value->course_name) >= 40) {
                    ?>
                    <span id="moreCourseName<?php echo $course_value->url ?>" style="cursor: pointer">more</span>
                    <?php
                }
                ?>
                <input type="hidden" id="hiddenCourseName<?php echo $course_value->url ?>" value="<?php echo $course_value->course_name ?>">
                <br>

                By- 
                <?php
                if(isset($course_creator_info[$course_value->course_id]->person_role)){
                if ($course_creator_info[$course_value->course_id]->person_role == 6 || $course_creator_info[$course_value->course_id]->person_role == 1) {
                    echo '<span class="green">Talha Training</span>';
                } else if ($course_creator_info[$course_value->course_id]->person_role == 3) {
                    ?>
                    <a href="<?php echo base_url() . $course_creator_info[$course_value->course_id]->url . '/profile' ?>" target="_blank">
                        <?php
                            //echo $course_creator_info[$course_value->course_id]->person_first_name . ' ' . $course_creator_info[$course_value->course_id]->person_last_name;
                            if (strlen($course_creator_info[$course_value->course_id]->person_first_name) && strlen($course_creator_info[$course_value->course_id]->person_last_name) < 40) {
                                echo $course_creator_info[$course_value->course_id]->person_first_name . ' ' . $course_creator_info[$course_value->course_id]->person_last_name;
                            } else {
                                echo substr($course_creator_info[$course_value->course_id]->person_first_name, 0, 30) . ' ' . substr($course_creator_info[$course_value->course_id]->person_last_name, 0, 20) . '.' . ' ' . '.' . ' ' . '.';
                            }
                        ?>
                    </a>
                    <?php
                } else if ($course_creator_info[$course_value->course_id]->person_role == 4) {
                    ?>
                    <a href="<?php echo base_url() . $course_creator_info[$course_value->course_id]->url . '/profile' ?>" target="_blank">
                        <?php
                            //echo $course_creator_info[$course_value->course_id]->person_first_name . ' ' . $course_creator_info[$course_value->course_id]->person_last_name;
                            if (strlen($course_creator_info[$course_value->course_id]->person_first_name) && strlen($course_creator_info[$course_value->course_id]->person_last_name) < 40) {
                                echo $course_creator_info[$course_value->course_id]->person_first_name . ' ' . $course_creator_info[$course_value->course_id]->person_last_name;
                            } else {
                                echo substr($course_creator_info[$course_value->course_id]->person_first_name, 0, 30) . ' ' . substr($course_creator_info[$course_value->course_id]->person_last_name, 0, 20) . '.' . ' ' . '.' . ' ' . '.';
                            }
                        ?>
                    </a>
                    <?php
                    }
                }else{
                    echo '<span class="green">Talha Training</span>';
                }
                ?>            
        </div>



      <!--  <div class="col-sm-2 form-group text-left" style="padding-left:0;">
            <?php
           // if ($course_value->course_type == 1) {
               // if ($course_price_info[$course_value->course_id]->price_currency == 1) {
                   // echo 'BDT ' . round($course_price_info[$course_value->course_id]->price);
              //  } elseif ($course_price_info[$course_value->course_id]->price_currency == 2) {
                   // echo 'USD ' . round($course_price_info[$course_value->course_id]->price);
               // }
           // } elseif ($course_value->course_type == 2) {
               // echo 'Call +8801712742217 for Price';
           // }
            ?>
        </div>-->



        <div class="col-sm-1 padding-zero form-group" style="text-align: left !important">
            <?php
            switch ($course_value->course_level) {
                case 0:
                    ?>
                    <span title="Any">
                        <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                        <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                        <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                    </span>
                    <?php
                    break;
                case 1:
                    ?>
                    <span title="Basic">
                        <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                        <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                        <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                    </span>
                    <?php
                    break;
                case 2:
                    ?>
                    <span title="Intermediate">
                        <img src="<?php echo base_url() . 'image/gray-box.jpg'; ?>" >
                        <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                        <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                    </span>
                    <?php
                    break;
                case 3:
                    ?>
                    <span title="Advanced">
                        <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                        <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                        <img src="<?php echo base_url() . 'image/green-box.jpg'; ?>" >
                    </span>
                    <?php
                    break;
            }
            ?>
        </div>



        <?php
        if ($person_id) {
            if (in_array($person_role, Array(3, 4, 5))) {
                ?>
                <div class="col-sm-3 form-group" style="text-align: left !important;padding: 5px">
                    <div id="ratingValue<?php echo $course_value->url ?>" class="rating-star">
                        <div class="rating-star-value" id="ratingDiv<?php echo $course_value->url ?>" style="width: <?php echo round(($course_value->course_rating * 100) / 5) ?>%"></div>
                        <div class="rating-star-bg"></div>
                    </div>
                </div>
            <?php } else {
                ?>
                <div class="col-sm-3 form-group" style="text-align: left !important;padding: 5px">
                    <div  class="rating-star">
                        <div class="rating-star-value" style="width: <?php echo round(($course_value->course_rating * 100) / 5) ?>%"></div>
                        <div class="rating-star-bg"></div>
                    </div>
                </div>
                <?php
            }
        } else {
            ?>
            <div class="col-sm-3 form-group" style="text-align: left !important;padding: 5px">
                <div  class="rating-star">
                    <div class="rating-star-value" style="width: <?php echo round(($course_value->course_rating * 100) / 5) ?>%"></div>
                    <div class="rating-star-bg"></div>
                </div>
            </div>
        <?php }
        ?>




        <div class="col-sm-2 form-group" style="padding-left:0;" style="text-align: left !important">
            <a href="<?php echo base_url() . 'course/' . $course_value->url . '/registration'; ?>" 
               data-toggle="tooltip" title="Get Enrollment in this Course" data-placement="top">
                <img src="<?php echo base_url() ?>image/registration-icon.png">
            </a>
        </div>
    </div>
    <input type="hidden" id="courseRating<?php echo $course_value->url ?>" value="<?php echo round(($course_value->course_rating * 100) / 5) ?>">
    <?php
}
echo '</div>';
echo $pagination_link;
