
<div class="col-sm-8">
    <div class="row gray">

        <div class="col-sm-12 ">
            <div class="col-sm-12">
                <h3>Assign Certificate to Quiz</h3>
                <hr>
                <nav class="text-justify">

                    <center>

                        <div class="col-sm-12">
                            <span class="clo-sm-3" title="Course Profile" style="padding: 0">
                                    <span class="number badge" style="background-color: gray">1</span>
                                    <span class="text-left label" style="color: #000;font-size: 14px;font-weight: normal">Certificate Information</span>
                                    <span class="nav-arrow" id="cborder" style="margin-right: 2px"><img src="<?php echo base_url(); ?>image/border.jpg"></span>
                            </span>

                            <span class="clo-sm-3" title="Add work Files" style="padding: 0">
                                    <span class="number badge" style="background-color: green;">2</span>
                                    <span class="text-left label" style="color: #000;font-size: 14px;font-weight: normal;padding: 0">Assign Certificate</span>
                            </span>

                        </div>
                    </center>

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

            <div class="col-sm-12"><br>
                <p>
                    <?php
                    $message = $this->session->userdata('message');
                    $this->session->unset_userdata('message');
                    if ($message) {
                        echo $message;
                    }
                    ?>
                </p>
            </div>

            <!--<div class="col-md-12" style="border: 1px solid green"></div>-->
            <div class="col-sm-12"><br></div>

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

                <div class="col-sm-12" style="max-height: 90px; overflow-y: auto;">
                    <?php foreach ($quizes as $v_quiz) { ?>
                        <div class="col-sm-4">
                            <span><?php echo $v_quiz->quiz_name; ?></span>
                        </div>
                    <?php } ?>
                </div>
                <div class="col-sm-12"><br></div>

                <?php echo validation_errors(); ?>
                <form class="cmxform" id="formID2" action="<?php echo base_url() . 'assign-certificate/' . $certificate_info->certificate_public_id; ?>" 
                      method="post" name="courseForm" enctype="multipart/form-data" >
                    <div class="col-sm-12">
                        <div class="col-sm-12"><br></div>
                        <div class="form-group col-sm-12">
                            <?php
                            // if ($group_details->group_permission == 4) { 
                            $to_address = '';
                            $selected_quiz = array();
                            foreach ($quiz_certificate as $v_quiz) {
                                $selected_quiz[$v_quiz->quiz_id] = TRUE;
                                $to_address .= $v_quiz->quiz_id . ',';
                            }
                            ?>


                            <input class="col-sm-12" type="hidden" name="previous_quizes" id="previous_quizes" value="<?php echo $to_address; ?>" >
                            <input class="col-sm-12" type="hidden" name="to_address" id="to_address" value="" >

                            <div class="col-sm-3 column"><h4> Select Quiz:</h4></div>
                            <div class="col-sm-9 column">
                                <select required  name="name_email" style="width: 280px;padding: 8px;" id="tokenize_placeholder" 
                                        class="tokenize-sample" multiple="multiple" style="margin: 0px; padding: 0px; border: 0px; display: none;">
                                            <?php foreach ($quizes as $v_quiz) { ?>
                                        <option value="<?php echo $v_quiz->quiz_id ?>" <?php
                                        if ($selected_quiz[$v_quiz->quiz_id] == TRUE) {
                                            echo 'selected';
                                        }
                                        ?>><?php echo $v_quiz->quiz_name . ' (' . $v_quiz->quiz_public_id . ')'; ?></option>
                                            <?php } ?>
                                </select>
                            </div>

                            <script type="text/javascript">
                                $('select#tokenize_placeholder').tokenize({placeholder: "Please Type Person Email or Name"});
                            </script>
                        </div>

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

                        <div class="col-sm-4">
                            <input type="submit" class="green-btn btn btn-default" name="btn" value="Assign Certificate">
                        </div>

                        <div class="col-sm-4">
                            <a href="<?php echo base_url() . 'skip-assign-certificate/'; ?>" class="green-btn btn btn-default" >Skip Assign Certificate</a>
                        </div>

                    </div>
                </form>

            </div>

        </div><!-- /.row gray -->


    </div>
</div>

<script>

    function _(el) {
        return document.getElementById(el);
    }


    function preview3() {

        var invitationMessage = tinyMCE.get('invitation_message').getContent({format: 'raw', no_events: 1});
//        alert(invitationMessage);
        var formdata = new FormData();
        formdata.append("message", invitationMessage);
        xmlhttp.open("POST", "<?php echo base_url() . 'preview_group_email/' . $group_details->url; ?>");

        xmlhttp.addEventListener("load", function () {
            _("email_preview").innerHTML = xmlhttp2.responseText;
        }, false);

        xmlhttp.send(formdata);
        document.getElementById('email_preview').innerHTML = xmlhttp.responseText;
    }
</script>