<?php
    $country_array = Countries::lists('country_name', 'country_code');
    $country_array = array_merge(array('' => 'Select Country'), $country_array);
    $paper_type_array = [
        ''  =>  'Select Oral or Poster',
        'O' =>  'Oral',
        'P' =>  'Poster',
    ];
    $meeting = Meetings::where('url', $url)->first();
    $meeting_topics_array = MeetingTopics::where('meeting_id', $meeting->id)->lists('title', 'id');
?>

<?php $__env->startSection('title', $meeting->title); ?>
<?php $__env->startSection('description', null); ?>
<?php $__env->startSection('keywords', null); ?>
<?php $__env->startSection('content'); ?>
    <div class="container">
        <div class="row">
            <div class="col-sm-12 content">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h1 class="panel-title">CHT-17 Online Submission Form</h1>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="jumbotron">
                                    <?php echo $meeting->description; ?>

                                </div>
                                <?php if($errors->any()): ?>
                                    <div class="row animated fadeIn">
                                        <div class="col-sm-12">
                                            <div class="alert alert-danger alert-dismissible" role="alert">
                                                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                <ul>
                                                    <?php foreach($errors->all() as $error): ?>
                                                        <li><?php echo $error; ?></li>
                                                    <?php endforeach; ?>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                <?php endif; ?>
                                <?php echo Form::open(array('url'=>route('form.submission.store'),'method'=>'post','enctype'=>'multipart/form-data','id'=>'create-account-form','autocomplete'=>'off')); ?>

                                <?php echo Form::hidden('process', $page); ?>

                                <?php echo Form::hidden('url', $url); ?>

                                <div class="row">
                                    <div class="col-sm-12">
                                        <h4 class="form-heading"><i class="fa fa-user" aria-hidden="true"></i> Corresponding Author's Information</h4>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="form-group col-sm-4">
                                        <?php echo Form::label('first_name', 'First Name', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Corresponding author\'s first name']); ?>

                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-user" aria-hidden="true"></i></span>
                                            <?php echo Form::text('first_name',Input::old('first_name'),array('id'=>'first_name','class'=>'form-control','placeholder'=>'First Name')); ?>

                                        </div>
                                    </div>
                                    <div class="form-group col-sm-4">
                                        <?php echo Form::label('middle_name', 'Middle Name Initial(s)', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Middle Name Initial(s)']); ?>

                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-user" aria-hidden="true"></i></span>
                                            <?php echo Form::text('middle_name',Input::old('middle_name'),array('id'=>'middle_name','class'=>'form-control','placeholder'=>'Middle Name Initial(s)')); ?>

                                        </div>
                                    </div>
                                    <div class="form-group col-sm-4">
                                        <?php echo Form::label('last_name', 'Last Name', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Corresponding author\'s last name']); ?>

                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-user" aria-hidden="true"></i></span>
                                            <?php echo Form::text('last_name',Input::old('last_name'),array('id'=>'last_name','class'=>'form-control','placeholder'=>'Last Name')); ?>

                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="form-group col-sm-4">
                                        <?php echo Form::label('email', 'Email', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Corresponding author\'s email']); ?>

                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-envelope-o" aria-hidden="true"></i></span>
                                            <?php echo Form::email('email',Input::old('email'),array('id'=>'email','class'=>'form-control','placeholder'=>'Primary Email for Correspondence')); ?>

                                        </div>
                                    </div>
                                    <div class="form-group col-sm-4">
                                        <?php echo Form::label('password', 'Password', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Password']); ?>

                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-key" aria-hidden="true"></i></span>
                                            <?php echo Form::password('password',array('id'=>'password','class'=>'form-control','placeholder'=>'Password for Correspondence')); ?>

                                        </div>
                                    </div>
                                    <div class="form-group col-sm-4">
                                        <?php echo Form::label('password_confirmation', 'Password Confirmation', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Password Confirmation']); ?>

                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-key" aria-hidden="true"></i></span>
                                            <?php echo Form::password('password_confirmation',array('id'=>'password_confirmation','class'=>'form-control','placeholder'=>'Password Confirmation')); ?>

                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="form-group col-sm-12">
                                        <?php echo Form::label('country', 'Corresponding Author\'s Country', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Corresponding Author\'s Country']); ?>

                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-globe" aria-hidden="true"></i> </span>
                                            <?php echo Form::select('country',$country_array,Input::old('country'),array('id'=>'country','class'=>'form-control')); ?>

                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-12">
                                        <?php echo Form::label('author', 'List of Authors in Order of Appearance in the Paper', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'List of Authors in Order of Appearance in the Paper']); ?>

                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-12" id="authors">
                                        <div class="row author" id="authorRow-0">
                                            <div class="form-group col-sm-5">
                                                <?php echo Form::label('author_firstname', 'Author\'s Name (as in the paper)', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Author\'s Name (as in the paper)']); ?>

                                                <div class="input-group">
                                                    <span class="input-group-addon"><i class="fa fa-globe" aria-hidden="true"></i> </span>
                                                    <?php echo Form::text('author_firstname[0]', null, array('id'=>'author_firstname','class'=>'form-control')); ?>

                                                </div>
                                            </div>
                                            <div class="form-group col-sm-5">
                                                <?php echo Form::label('author_lastname', 'Author\'s Last Name (as in the paper)', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Author\'s Last Name (as in the paper)']); ?>

                                                <div class="input-group">
                                                    <span class="input-group-addon"><i class="fa fa-globe" aria-hidden="true"></i> </span>
                                                    <?php echo Form::text('author_lastname[0]', null, array('id'=>'author_lastname','class'=>'form-control')); ?>


                                                </div>
                                            </div>
                                            <div class="form-group col-sm-2">
                                                <label for="author_remove">Remove</label>
                                                <button name="author_remove[0]" id="author_remove_0" type="button" class="btn btn-danger btn-block author-remove"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group col-sm-12">
                                        <button name="author_add" id="author_add" type="button" class="btn btn-success btn-block"><span class="glyphicon glyphicon-plus" aria-hidden="true" style="margin-left:15px;"></span> Add one more author</button>
                                    </div>
                                </div>
                                <script>
                                    var current_id = 0;
                                    $('#author_add').click(function(){
                                        addAccompanyingPerson($('#authorRow-0'));
                                    });
                                    function addAccompanyingPerson(element){
                                        var newElement = element.clone(true);
                                        var id = current_id+1;
                                        current_id = id;
                                        if (current_id >= 4) {
                                            $('#author_add').addClass('disabled');
                                        } else {
                                            $('#author_add').removeClass('disabled');
                                        }
                                        newElement.attr("id",element.attr("id").split("-")[0]+"-"+id);
                                        var firstNameField = $('#author_firstname', newElement).attr("name");
                                        var lastnameField = $('#author_lastname', newElement).attr("name");
                                        var removeButton = $('.author-remove', newElement).attr("id");
                                        $('#author_firstname', newElement).attr("name", firstNameField.split("[")[0]+"["+id+"]");
                                        $('#author_lastname', newElement).attr("name", lastnameField.split("[")[0]+"["+id+"]");
                                        $('.author-remove', newElement).attr("id", removeButton.split("author_remove_")[0]+"author_remove_"+id);
                                        newElement.appendTo($("#authors"));
                                    }
                                    $(".author-remove").click(function () {
                                        var thisID = $(this).attr('id');
                                        if (thisID == "author_remove_0"){} else {
                                            $(this).closest(".author").remove();
                                            var id = current_id-1;
                                            current_id = id;
                                            if (current_id <= 4) {
                                                $('#author_add').removeClass('disabled');
                                            }
                                        }
                                    });
                                </script>
                                <div class="row">
                                    <div class="col-sm-12">
                                        <h4 class="form-heading"><i class="fa fa-paperclip" aria-hidden="true"></i> Paper Information</h4>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="form-group col-sm-12">
                                        <?php echo Form::label('paper_title', 'Paper Title', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Paper Title']); ?>

                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-paper-plane-o" aria-hidden="true"></i></span>
                                            <?php echo Form::text('paper_title',Input::old('paper_title'),array('id'=>'paper_title','class'=>'form-control','placeholder'=>'Maximum Char Allowed 250')); ?>

                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="form-group col-sm-12">
                                        <?php echo Form::label('meeting_topic', 'Select Subject Code', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Select Subject Code']); ?>

                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-globe" aria-hidden="true"></i> </span>
                                            <?php echo Form::select('meeting_topic',$meeting_topics_array,Input::old('meeting_topic'),array('id'=>'meeting_topic','class'=>'form-control')); ?>

                                        </div>
                                    </div>
                                </div>
                                <?php if($page != 'W'): ?>
                                <div class="row">
                                    <div class="form-group col-sm-12">
                                        <?php echo Form::label('paper_type', 'Select Oral or Poster Presentation', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Select Oral or Poster Presentation']); ?>

                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-globe" aria-hidden="true"></i> </span>
                                            <?php echo Form::select('paper_type',$paper_type_array,Input::old('paper_type'),array('id'=>'paper_type','class'=>'form-control')); ?>

                                        </div>
                                    </div>
                                </div>
                                <?php endif; ?>
                                <div class="row">
                                    <div class="form-group col-sm-12">
                                        <?php echo Form::label('paper_document', 'Submit Paper (or Abstract for Poster Presentation)', ['data-toggle'=>'tooltip','data-placement'=>'top','title'=>'Submit Paper (or Abstract for Poster Presentation)']); ?>

                                        <div class="input-group">
                                            <span class="input-group-addon"><i class="fa fa-paperclip" aria-hidden="true"></i></span>
                                            <span class="btn btn-default btn-file btn-block">
                                                <span class="filename">Choose PDF File & Upload</span> <?php echo Form::file('paper_document',['accept'=>'application/pdf']); ?>

                                            </span>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-12">
                                        <?php echo Form::submit('Submit Form',array('class'=>'btn btn-lg btn-default btn-block')); ?>

                                    </div>
                                </div>
                                <?php echo Form::close(); ?>

                                <script type="text/javascript">
                                    $(function() {
                                        $("input:file").change(function (){
                                            var fileName = $(this).val();
                                            if (fileName.length > 0){
                                                $(".filename").html(fileName);
                                            } else {
                                                $(".filename").html('Choose PDF File & Upload');
                                            }
                                        });
                                    });
                                </script>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout.common', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>