<div class="col-sm-8 col-sm-offset-2">

    <div class="row gray_ttc">

        <div class="col-sm-12 ">
            <div class="col-sm-12">
                <h3>Update Work File</h3>  
                <hr>

                <nav class="text-justify">
                    <center>
                        <div class="col-sm-12" style="padding: 0">
                            <span class="clo-sm-4" title="" style="padding: 0">
                                <a href="" style="cursor:default;">
                                    <span class="number badge" style="background-color: gray">1</span>
                                    <span class="text-left label" style="color: #000;font-size: 16px;font-weight: normal">Add Tutorial </span>
                                    <span class="nav-arrow" id="cborder" style="margin-right: 8px"><img src="images/border.jpg"></span>
                                </a>
                            </span>


                            <span class="clo-sm-4" title="Add Topics" style="padding: 0">
                                <a href="" style="cursor:default;">
                                    <span class="number badge" style="background-color: gray">2</span>
                                    <span class="text-left label" style="color: #000 ;font-size: 16px;font-weight: normal">Add Topics</span>
                                    <span class="nav-arrow" id="cborder" style="margin-right: 8px"><img src="images/border.jpg"></span>
                                </a>
                            </span>



                            <span class="clo-sm-4" title="Add work file" style="padding: 0">
                                <a href="" style="cursor:default;">
                                    <span class="number badge" style="background-color: green">3</span>
                                    <span class="text-left label" style="color: #000;font-size: 16px;font-weight: normal">Add work file</span>
                                </a>
                            </span>

                        </div>
                    </center>

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

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


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

                <form action="<?php echo base_url() ?>update-tutorial-work-file" method="post" name="edit_work_file_form" >
                    <input type="hidden" name="tutorial_id" value="<?php echo $tutorial_id ?>">
                    <input type="hidden" name="tutorial_file_section" value="" id="tutorial_file_section">
                    <!--<div class="col-sm-12  ">-->
                    <div id="add_more_work_file">  

                        <?php
                        $i = 0;
                        foreach ($tutorial_work_file as $v_tutorial_work_file) {
                            ?>     

                            <div id="add_work_file">    

                                <div class="col-sm-12"><br> </div>
                                <div class="form-group col-sm-8 col-sm-offset-2 " style="background-color: limegreen;padding: 1px">
                                    <input  value="<?php echo $v_tutorial_work_file->work_files_management_id;?>" type="hidden" name="work_files_management_id[]" >
                                    <input type="text" class="form-control" value="<?php echo $v_tutorial_work_file->work_files_name ?>" name="tutorial_work_file_name[]" placeholder="Please type work file name">
                                </div>
                                <div class="col-sm-12"><br> </div>
                                <div class="form-group col-sm-4 col-sm-offset-2 " style="background-color: limegreen;padding: 1px"> 
                                    <input type="file" class="form-control" name="tutorial_work_file[]">
                                </div> 
                                <div class="form-group col-sm-4">
                                    <input type="hidden" value="<?php echo $v_tutorial_work_file->work_files_url ?>" class="form-control" name="tutorial_work_file[]">
                                    <?php echo $v_tutorial_work_file->work_files_url ?>
                                
                                </div> 
        
                                <div class="col-sm-12"><br> </div>
                                <div class="form-group col-sm-8 col-sm-offset-2">
                                    <label for="tutorial_work_file_status">Tutorial Work File Status</label><span class="required"> * <?php echo form_error('status'); ?></span>
                                    <input  type="radio" 
                                            data-errormessage-value-missing="Tutorial Work file Status is Required!" 
                                            class="validate[required]] text-input"  
                                            name="tutorial_work_file_status[<?php echo $i;?>]" 
                                            id="tutorial_work_file_status"
                                            value="1"/>Published
                                    <input type="radio" 
                                           data-errormessage-value-missing="Tutorial work file Status is Required!" 
                                           class="validate[required]] text-input"  
                                           name="tutorial_work_file_status[<?php echo $i;?>]" 
                                           id="tutorial_work_file_status" 
                                           value="0"/>Unpublished
                                    <script>
                                        document.forms['edit_work_file_form'].elements['tutorial_work_file_status[<?php echo $i; ?>]'].value = <?php echo $v_tutorial_work_file->work_files_status ?>;
                                    </script>
                                </div>

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

                            </div>
                        
                          
                        
                        <?php $i++; } ?>    

                    </div>

                    <div id="add_more_work_file"></div>


                    <div class="col-sm-12"><br></div>
                    <div class="col-sm-2"></div>
                    <div class="form-group col-sm-4">
                        <a href="#" onclick="AddMoreWorkFile('add_more_work_file')" class="green-btn btn btn-success" >Add More Work File </a>
                    </div>
                    <div class="col-sm-2">
                        <input type="submit" class="green-btn btn btn-default" value="Add Tutorial !"><br/><br/>
                    </div>
                    <div class="col-sm-2">
                        <a href="#" onclick="" class="green-btn btn btn-success" >Skip </a>
                    </div>

                    <div class="col-sm-4"></div>




                </form>
            </div>

        </div>

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

</div>

<script>

    var Counter = <?php echo $i-1?>;


    function AddMoreWorkFile() {

        Counter++;

        serverPage = '<?php echo base_url(); ?>add-more-tutorial-work-file' + '/' + Counter;
//        alert(serverPage);
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
//                alert(counter);
//            alert(xmlhttp.readyState);
//            alert(xmlhttp.status);
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
            {
//                alert(xmlhttp.responseText);
                var parent = document.getElementById('add_more_work_file');
                var div1 = document.createElement('div');
                div1.setAttribute('id', 'tutorial_file_section' + Counter);
                parent.appendChild(div1);
                var data1 = xmlhttp.responseText;
                div1.innerHTML = data1;
            }
        }
        xmlhttp.send(null);
        document.getElementById('tutorial_file_section').value = Counter;
//            fileCounter++;
//            alert(fileCounter);

    }

</script>