<?php
if($topic_info){
$topic_id = $topic_info->quiz_topic_id;
$status = $topic_info->topic_status;

$topic_creator_role = $topic_creator[$topic_info->quiz_topic_id]->person_role;
$topic_viewer_role = $this->session->userdata('person_role');
?>
<div id="actions<?php echo $topic_id; ?>">
    <div class="col-sm-12 gray text-center" >
        <div class="col-sm-4" style="padding:10px 0"><?php echo $topic_info->topic_name; ?></div>
        <div class="col-sm-3" style="padding:10px 0">
            <?php
            if ($topic_creator_role == 6) {
                echo 'TalhaTraining';
            } else if ($topic_creator_role == 1) {
                echo 'TalhaTraining';
            } else if ($topic_creator_role == 3) {
                echo $topic_creator[$topic_info->quiz_topic_id]->person_first_name . ' ' . $topic_creator->person_last_name;
            } else if ($topic_creator_role == 4) {
                echo $org_info[$topic_info->quiz_topic_id]->organization_name;
            }
            ?>
        </div>

        <div class="col-sm-4" style="padding:10px 0">

            <a href="<?php echo base_url() . 'super-admin/edit-quiz-topic/' . $topic_id; ?>">
                <i class="fa fa-edit" title="Edit topic"></i>
            </a>&nbsp;&nbsp;

            <?php
            switch ($topic_viewer_role) {
                case 1:
                    ?>
                    <?php
                    switch ($status) {
                        case 0:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/1'; ?>', 'Publish', '<?php echo $topic_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;

                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/3'; ?>', 'Pending', '<?php echo $topic_id; ?>')">
                                <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                            </a>&nbsp;&nbsp;

                            <?php
                            break;
                        case 1:
                            if (!$topic_quizes[$topic_id]) {
                                ?>
                                <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/0'; ?>', 'Unpublish', '<?php echo $topic_id; ?>')">
                                    <i class="fa  fa-user-times" title="Unpublish"></i>
                                </a>&nbsp;&nbsp;

                                <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/3'; ?>', 'Pending', '<?php echo $topic_id; ?>')">
                                    <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                                </a>&nbsp;&nbsp;
                            <?php } ?>
                            <?php
                            break;
                        case 2:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/1'; ?>', 'Publish', '<?php echo $topic_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/0'; ?>', 'Unpublish', '<?php echo $topic_id; ?>')">
                                <i class="fa  fa-user-times" title="Unpublish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/4'; ?>', 'Approve', '<?php echo $topic_id; ?>')">
                                <i class="glyphicon glyphicon-ok" title="Approve topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        case 3:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/4'; ?>', 'Approve', '<?php echo $topic_id; ?>')">
                                <i class="glyphicon glyphicon-ok" title="Approve topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        case 4:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/1'; ?>', 'Publish', '<?php echo $topic_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/3'; ?>', 'Pending', '<?php echo $topic_id; ?>')">
                                <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        default:
                            break;
                    }
                    ?>
                    <?php if (!$topic_quizes[$topic_id]) { ?>
                        <a  href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/delete-topic/' . $topic_id; ?>', 'Delete', '<?php echo $topic_id; ?>')">
                            <i class="fa fa-trash-o" title="Delete"></i>
                        </a>&nbsp;&nbsp;
                    <?php } ?>
                    <?php
                    break;
                case 6:
                    ?>
                    <?php
                    switch ($status) {
                        case 0:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/1'; ?>', 'Publish', '<?php echo $topic_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;

                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/3'; ?>', 'Pending', '<?php echo $topic_id; ?>')">
                                <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                            </a>&nbsp;&nbsp;

                            <?php
                            break;
                        case 1:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/0'; ?>', 'Unpublish', '<?php echo $topic_id; ?>')">
                                <i class="fa  fa-user-times" title="Unpublish"></i>
                            </a>&nbsp;&nbsp;

                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/3'; ?>', 'Pending', '<?php echo $topic_id; ?>')">
                                <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        case 2:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/1'; ?>', 'Publish', '<?php echo $topic_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/0'; ?>', 'Unpublish', '<?php echo $topic_id; ?>')">
                                <i class="fa  fa-user-times" title="Unpublish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/4'; ?>', 'Approve', '<?php echo $topic_id; ?>')">
                                <i class="glyphicon glyphicon-ok" title="Approve topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        case 3:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/4'; ?>', 'Approve', '<?php echo $topic_id; ?>')">
                                <i class="glyphicon glyphicon-ok" title="Approve topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        case 4:
                            ?>
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/1'; ?>', 'Publish', '<?php echo $topic_id; ?>')">
                                <i class="fa  fa-user-plus" title="Publish"></i>
                            </a>&nbsp;&nbsp;
                            <a href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/change-status/' . $topic_id . '/3'; ?>', 'Pending', '<?php echo $topic_id; ?>')">
                                <i class="fa fa-refresh fa-spin" title="Pending topic"></i>
                            </a>&nbsp;&nbsp;
                            <?php
                            break;
                        default:
                            break;
                    }
                    ?>

                    <a  href="javascript:void(0)" onclick="return checkForAction('<?php echo base_url() . 'super-admin/delete-topic/' . $topic_id; ?>', 'Delete', '<?php echo $topic_id; ?>')">
                        <i class="fa fa-trash-o" title="Delete"></i>
                    </a>&nbsp;&nbsp;
                    <?php
                    break;
            }
            ?>
            <a  href="<?php echo base_url() . 'super-admin/view-topic-quiz/' . $topic_id; ?>" >
                <i class="fa fa-th" title="View quiz"></i>
            </a>&nbsp;&nbsp;
        </div>
    </div>
    <div class="col-sm-12"><br></div> 
</div>
<?php } ?>