<div class="page-content-wrapper">
    <div class="page-content">
        <div class="row">
            <div class="col-md-12">
                <!-- BEGIN EXAMPLE TABLE PORTLET-->
                <div class="portlet box blue">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="fa fa-user"></i>Vote
                        </div>
                    </div>
                    <div class="portlet-body">

                        <!--Begin Semen-->

                        <div class="row">

                            <div class="portlet-title tbox">
                                <div class="caption font-blue-haze col-md-6">
                                    <span class="caption-subject bold uppercase">Edit form</span>
                                </div>

                            </div>

                            <div class="clearfix"></div>

                            <form action="{$hosturl}/controllers/{$controllname}.php?ac=update" class="clinick vote-form" method="post">

                                <div class="form-body">
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">Device</label>
                                            <div class="col-md-9">
                                                <select class="form-control select2me" required="required" name="vote_device_id" data-placeholder="Select...">
                                                    <option></option>
                                                    {foreach $vote_devices as $single}
                                                        <option value="{$single->id}" {if $single->id eq $vote->vote_device_id} selected {/if}>{$single->name}</option>
                                                    {/foreach}
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label class="col-md-5 control-label">Voter required</label>
                                            <div class="col-md-7">
                                                <div class="radio-list">
                                                    <label class="radio-inline">
                                                        <input type="radio" name="voter_required" value="1" {if 1 eq $vote->voter_required} checked {/if}> Yes </label>
                                                    <label class="radio-inline">
                                                        <input type="radio" name="voter_required" value="0" {if 0 eq $vote->voter_required} checked {/if}> No </label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">Email</label>
                                            <div class="col-md-10">
                                                <input class="form-control" name="email" required type="text" email="true" value="{$vote->email}">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-3">
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">Role</label>
                                            <div class="col-md-10">
                                                <select class="form-control select2me" required="required" name="role_id" data-placeholder="Select...">
                                                    <option></option>
                                                    {foreach $roles as $single}
                                                        <option value="{$single->id}" {if $single->id eq $vote->role_id} selected {/if}>{$single->name}</option>
                                                    {/foreach}
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="clearfix"></div>
                                    <hr>
                                    <h4 style="text-decoration: underline;">
                                        <strong>Questions</strong>
                                        <button type="button" class="btn blue-madison pull-right" id="append-vote-question">Add Question</button>
                                    </h4>
                                    <div class="clearfix"></div>

                                    <ul class="list-group" style="margin-top: 15px;" id="vote_question_container">
                                        {assign var=qu_itr value=1}
                                        {foreach $questions as $question}
                                            <li class="list-group-item row" style="margin-bottom: 10px !important;">
                                                <div class="form-group col-md-11">
                                                    <label class="col-md-3 control-label">Question {$qu_itr}</label>
                                                    <div class="col-md-9">
                                                        <input type="text" class="form-control" name="question_{$qu_itr}" value="{$question->question}" required>
                                                        <input type="hidden" name="question_id_{$qu_itr}" value="{$question->id}">
                                                    </div>
                                                </div>
                                                {if $qu_itr gt 1}
                                                    <div class="col-md-1 pull-right">
                                                        <button type="button" class="btn btn-sm spinner-down red remove-vote-question" data-edit-mode="1" data-question-id="{$question->id}">
                                                            <i class="fa fa-minus"></i>
                                                        </button>
                                                    </div>
                                                {/if}
                                                <div class="form-group col-md-2">
                                                    <label class="control-label">Answers:</label>
                                                </div>
                                                <div class="form-group col-md-2">
                                                    <input type="text" class="form-control" placeholder="Answer 1" name="answer_1_{$qu_itr}" value="{$question->answers[0].answer}" required>
                                                    <input type="hidden" name="answer_id_1_{$qu_itr}" value="{$question->answers[0].id}">
                                                    <label class="col-md-11 control-label bold">Send Email
                                                        <span style="float: left;">
                                                        <input type="checkbox" class="checkGroup" value="1" name="send_mail_1_{$qu_itr}" {if $question->answers[0].send_mail eq 1} checked {/if}>
                                                    </span>
                                                    </label>
                                                    <select class="form-control select2me" required="required" name="face_1_{$qu_itr}" data-placeholder="Select...">
                                                        <option value="happy" {if $question->answers[0].face eq "happy" or empty($question->answers[0].face)} selected {/if}>&#128513; &nbsp; happy
                                                        </option>
                                                        <option value="good" {if $question->answers[0].face eq "good"} selected {/if}>&#128523; &nbsp; good</option>
                                                        <option value="ok" {if $question->answers[0].face eq "ok"} selected {/if}>&#128528; &nbsp; ok</option>
                                                        <option value="sad" {if $question->answers[0].face eq "sad"} selected {/if}>&#128542; &nbsp; sad</option>
                                                        <option value="angry" {if $question->answers[0].face eq "angry"} selected {/if}>&#128545; &nbsp; angry</option>
                                                    </select>
                                                </div>
                                                <div class="form-group col-md-2">
                                                    <input type="text" class="form-control" placeholder="Answer 2" name="answer_2_{$qu_itr}" value="{$question->answers[1].answer}" required>
                                                    <input type="hidden" name="answer_id_2_{$qu_itr}" value="{$question->answers[1].id}">
                                                    <label class="col-md-11 control-label bold">Send Email
                                                        <span style="float: left;">
                                                        <input type="checkbox" class="checkGroup" value="1" name="send_mail_2_{$qu_itr}" {if $question->answers[1].send_mail eq 1} checked {/if}>
                                                    </span>
                                                    </label>
                                                    <select class="form-control select2me" required="required" name="face_2_{$qu_itr}" data-placeholder="Select...">
                                                        <option value="happy" {if $question->answers[1].face eq "happy"} selected {/if}>&#128513; &nbsp; happy</option>
                                                        <option value="good" {if $question->answers[1].face eq "good" or empty($question->answers[1].face)} selected {/if}>&#128523; &nbsp; good
                                                        </option>
                                                        <option value="ok" {if $question->answers[1].face eq "ok"} selected {/if}>&#128528; &nbsp; ok</option>
                                                        <option value="sad" {if $question->answers[1].face eq "sad"} selected {/if}>&#128542; &nbsp; sad</option>
                                                        <option value="angry" {if $question->answers[1].face eq "angry"} selected {/if}>&#128545; &nbsp; angry</option>
                                                    </select>
                                                </div>
                                                <div class="form-group col-md-2">
                                                    <input type="text" class="form-control" placeholder="Answer 3" name="answer_3_{$qu_itr}" value="{$question->answers[2].answer}" required>
                                                    <input type="hidden" name="answer_id_3_{$qu_itr}" value="{$question->answers[2].id}">
                                                    <label class="col-md-11 control-label bold">Send Email
                                                        <span style="float: left;">
                                                        <input type="checkbox" class="checkGroup" value="1" name="send_mail_3_{$qu_itr}" {if $question->answers[2].send_mail eq 1} checked {/if}>
                                                    </span>
                                                    </label>
                                                    <select class="form-control select2me" required="required" name="face_3_{$qu_itr}" data-placeholder="Select...">
                                                        <option value="happy" {if $question->answers[2].face eq "happy"} selected {/if}>&#128513; &nbsp; happy</option>
                                                        <option value="good" {if $question->answers[2].face eq "good"} selected {/if}>&#128523; &nbsp; good</option>
                                                        <option value="ok" {if $question->answers[2].face eq "ok" or empty($question->answers[2].face)} selected {/if}>&#128528; &nbsp; ok</option>
                                                        <option value="sad" {if $question->answers[2].face eq "sad"} selected {/if}>&#128542; &nbsp; sad</option>
                                                        <option value="angry" {if $question->answers[2].face eq "angry"} selected {/if}>&#128545; &nbsp; angry</option>
                                                    </select>
                                                </div>
                                                <div class="form-group col-md-2">
                                                    <input type="text" class="form-control" placeholder="Answer 4" name="answer_4_{$qu_itr}" value="{$question->answers[3].answer}">
                                                    <input type="hidden" name="answer_id_4_{$qu_itr}" value="{$question->answers[3].id}">
                                                    <label class="col-md-11 control-label bold">Send Email
                                                        <span style="float: left;">
                                                        <input type="checkbox" class="checkGroup" value="1" name="send_mail_4_{$qu_itr}" {if $question->answers[3].send_mail eq 1} checked {/if}>
                                                    </span>
                                                    </label>
                                                    <select class="form-control select2me" name="face_4_{$qu_itr}" data-placeholder="Select...">
                                                        <option {if empty($question->answers[3].face)} selected {/if}></option>
                                                        <option value="happy" {if $question->answers[3].face eq "happy"} selected {/if}>&#128513; &nbsp; happy</option>
                                                        <option value="good" {if $question->answers[3].face eq "good"} selected {/if}>&#128523; &nbsp; good</option>
                                                        <option value="ok" {if $question->answers[3].face eq "ok" } selected {/if}>&#128528; &nbsp; ok</option>
                                                        <option value="sad" {if $question->answers[3].face eq "sad"} selected {/if}>&#128542; &nbsp; sad</option>
                                                        <option value="angry" {if $question->answers[3].face eq "angry"} selected {/if}>&#128545; &nbsp; angry</option>
                                                    </select>
                                                </div>
                                                <div class="form-group col-md-2">
                                                    <input type="text" class="form-control" placeholder="Answer 5" name="answer_5_{$qu_itr}" value="{$question->answers[4].answer}">
                                                    <input type="hidden" name="answer_id_5_{$qu_itr}" value="{$question->answers[4].id}">
                                                    <label class="col-md-11 control-label bold">Send Email
                                                        <span style="float: left;">
                                                        <input type="checkbox" class="checkGroup" value="1" name="send_mail_5_{$qu_itr}" {if $question->answers[4].send_mail eq 1} checked {/if}>
                                                    </span>
                                                    </label>
                                                    <select class="form-control select2me" name="face_5_{$qu_itr}" data-placeholder="Select...">
                                                        <option {if empty($question->answers[4].face)} selected {/if}></option>
                                                        <option value="happy" {if $question->answers[4].face eq "happy"} selected {/if}>&#128513; &nbsp; happy</option>
                                                        <option value="good" {if $question->answers[4].face eq "good"} selected {/if}>&#128523; &nbsp; good</option>
                                                        <option value="ok" {if $question->answers[4].face eq "ok" } selected {/if}>&#128528; &nbsp; ok</option>
                                                        <option value="sad" {if $question->answers[4].face eq "sad"} selected {/if}>&#128542; &nbsp; sad</option>
                                                        <option value="angry" {if $question->answers[4].face eq "angry"} selected {/if}>&#128545; &nbsp; angry
                                                        </option>
                                                    </select>
                                                </div>
                                            </li>
                                            {capture assign=qu_itr}{$qu_itr+1}{/capture}
                                        {/foreach}
                                    </ul>

                                    <input type="hidden" id="vote_questions_itr" name="vote_questions_itr" value="{$questions|@count}"/>

                                </div>
                                <input type="hidden" name="id" value="{$vote->id}">

                                <div class="form-actions">
                                    <div class="row">
                                        <div class="col-md-offset-2 col-md-10">
                                            <a class="btn default" href="{$hosturl}/controllers/{$controllname}.php?ac=show">Cancel</a>
                                            <button class="btn blue" type="submit">Submit</button>

                                        </div>
                                    </div>
                                </div>
                            </form>

                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>


