{#
    LimeSurvey
    Copyright (C) 2007-2017 The LimeSurvey Project Team / Louis Gac
    All rights reserved.
    License: GNU/GPL License v2 or later, see LICENSE.php
    LimeSurvey is free software. This version may have been modified pursuant
    to the GNU General Public License, and as distributed it includes or
    is derivative of works licensed under the GNU General Public License or
    other free or open source software licenses.
    See COPYRIGHT.php for copyright notices and details.

    (¯`·._.·(¯`·._.· Save page Content  ·._.·´¯)·._.·´¯)

    This file displays the page shown to a respondent when they save the survey to complete later.

    Depending on survey config, a navigator allowing the respondent to change their responses can be shown, and a end url.

    Form data are in: aSurveyInfo.aSaveForm (errors, css classes, captcha, etc)
    To show this data, turn debug mode on and copy the following line to the end of the <body> element in this file:
    {{ dump(aSurveyInfo.aSaveForm ) }} )

    (¯`·._.·(¯`·._.·  Advanced ·._.·´¯)·._.·´¯)

    The form is generated using the Yii function CHtml::form. You must keep it to get the CRSF token.
    Inputs are also generated using the Yii function CHtml. Eg: input textField is generated via CHtml::textField
    You can replace those inputs by pure Html (<input type="text" ... />), just be sure to use the correct options (id, classes, required, etc)
    @see: http://www.yiiframework.com/wiki/48/by-example-chtml/ , http://www.yiiframework.com/doc/api/1.1/CHtml

    NOTE: This content is included inside mainrow.twig
    NOTE: see layout_global.twig for more infos
#}




{# Include the form opening tag #}
{{ include('./subviews/header/start_form.twig') }} <!-- main form -->

    {# This will display the script and the hidden inputs needed for Expression Manager #}
    {{ aSurveyInfo.EM.ScriptsAndHiddenInputs  }}

    <div class="{{ aSurveyInfo.class.savecontainer }} well clearfix " {{ aSurveyInfo.attr.savecontainer }}>
        <div class="{{ aSurveyInfo.class.savecontainertitle }} h2" {{ aSurveyInfo.attr.savecontainertitle }}>{{ gT("Save your unfinished survey") }}</div>
        <div class="{{ aSurveyInfo.class.savecontainertext }} text-info" {{ aSurveyInfo.attr.savecontainertext }}>
            <p {{ aSurveyInfo.attr.savecontainertextpa }}> {{ gT("Enter a name and password for this survey and click save below.") }} </p>
            <p {{ aSurveyInfo.attr.savecontainertextpb }}> {{ gT("Your survey will be saved using that name and password, and can be completed later by logging in with the same name and password.") }} </p>
            <p class='{{ aSurveyInfo.class.savecontainertextpc }}' {{ aSurveyInfo.attr.savecontainertextpc }}> {{ gT("If you give an email address, an email containing the details will be sent to you.") }} </p>
            <p {{ aSurveyInfo.attr.savecontainertextpd }}> {{ gT("After having clicked the save button you can either close this browser window or continue filling out the survey.") }} </p>
        </div>
        <div class="{{ aSurveyInfo.class.savecontainerwarning }} text-warning" {{ aSurveyInfo.attr.savecontainerwarning }}>
            <p> {{ gT("To remain anonymous please use a pseudonym as your username, also an email address is not required.") }} </p>
        </div>
    </div>

    <div class="{{ aSurveyInfo.class.saveformcontainer }}" {{ aSurveyInfo.attr.saveformcontainer }}>

        {% if count(aSurveyInfo.aSaveForm.aErrors) > 0 %}
            <ul class='{{ aSurveyInfo.aSaveForm.sClass }}  {{ aSurveyInfo.class.saveformcontainerul }} alert alert-danger list-unstyled '  >
                {% for key,error in aSurveyInfo.aSaveForm.aErrors %}
                    <li {{ aSurveyInfo.attr.saveformcontainerli }} >{{ error }}</li>
                    {% endfor %}
            </ul>
        {% endif %}

        {#
            array of attributes of the form tag.
            To add a new attribute, just add an entry:
            'attribute' : 'value',
        #}
        {% set htmlOptions = {
                'id'          : 'form-save',
                'name'        : 'form-save',
                'class'       : 'ls-form',
            }
        %}

        {#
            This generates the opening form tag and the CRSF token.
            It uses the Yii fuction CHtml::form.
            See: http://www.yiiframework.com/doc/api/1.1/CHtml#form-detail
        #}
        <!-- Save Form -->
        {{
            C.Html.form(
                ( aSurveyInfo.surveyUrl ),
                'post',
                (htmlOptions)
            )
        }}
            <!-- Hidden fields  -->
            {{  aSurveyInfo.aSaveForm.sHiddenField }}

            <!-- Name and Password -->
            <div class='{{ aSurveyInfo.class.saveformsurvey }} form-horizontal' {{ aSurveyInfo.attr.saveformsurvey }}>
                <div class='{{ aSurveyInfo.class.saveformsurveydiva }} form-group ' {{ aSurveyInfo.attr.saveformsurveydiva }}>

                    <!-- Saved name  -->
                    <label class='{{ aSurveyInfo.class.saveformsurveydivalabel }} control-label col-sm-3' {{ aSurveyInfo.attr.saveformsurveydivalabel }}>
                        {{ gT("Name:") }}
                        <small class="{{ aSurveyInfo.class.saveformsurveydivalabelsmall }} text-danger asterisk fa fa-asterisk pull-left small " {{ aSurveyInfo.attr.saveformsurveydivalabelsmall }} ></small>
                        <span class="{{ aSurveyInfo.class.saveformsurveydivalabelspan }} sr-only text-danger asterisk" {{ aSurveyInfo.attr.saveformsurveydivalabelspan }}>{{ gT("Mandatory") }}<span>
                    </label>
                    <div class='{{ aSurveyInfo.class.saveformsurveydivb }} col-sm-7 ' {{ aSurveyInfo.attr.saveformsurveydivb }}>

                        {% set htmlOptions = {
                                'id'          : 'savename',
                                'name'        : 'savename',
                                'class'       : 'form-control',
                                'required'    : true,
                            }
                        %}

                        {# using CHtml::textField because it encode (and break XSS) #}
                        {{ C.Html.textField(
                                'savename',
                                getPost('savename'),
                                (htmlOptions)
                        )  }}
                    </div>

                </div>

                <!-- Password -->
                <div class='{{ aSurveyInfo.class.saveformsurveydivc }} form-group' {{ aSurveyInfo.attr.saveformsurveydivc }}>
                    <label class='{{ aSurveyInfo.class.saveformsurveydivclabel }} control-label col-sm-3 ' {{ aSurveyInfo.attr.saveformsurveydivclabel }}>
                        {{ gT("Password:") }}
                        <small class="{{ aSurveyInfo.class.saveformsurveydivcsmall }} text-danger asterisk fa fa-asterisk pull-left small" {{ aSurveyInfo.attr.saveformsurveydivcsmall }} ></small>
                        <span class="{{ aSurveyInfo.class.saveformsurveydivcspan }} sr-only text-danger asterisk" {{ aSurveyInfo.attr.saveformsurveydivcspan }}>{{ gT("Mandatory") }}<span>
                    </label>

                    <div class='{{ aSurveyInfo.class.saveformsurveydivcdiv }} col-sm-7 ' {{ aSurveyInfo.attr.saveformsurveydivcdiv }}>

                        {% set htmlOptions = {
                                'id'          : 'savepass',
                                'name'        : 'savepass',
                                'class'       : 'form-control',
                                'required'    : true,
                            }
                        %}

                        {{ C.Html.passwordField(
                                'savepass',
                                '',
                                (htmlOptions)
                        )  }}
                    </div>
                </div>

                <!-- Confirm password -->
                <div class='{{ aSurveyInfo.class.saveformsurveydivd }} form-group ' {{ aSurveyInfo.attr.saveformsurveydivd }}>
                    <label class='{{ aSurveyInfo.class.saveformsurveydivdlabel }} control-label col-sm-3 ' {{ aSurveyInfo.attr.saveformsurveydivdlabel }} >
                        {{ gT("Repeat password:") }}
                        <small class="{{ aSurveyInfo.class.saveformsurveydivdlabelsmall }}  text-danger asterisk fa fa-asterisk pull-left small" {{ aSurveyInfo.attr.saveformsurveydivdlabelsmall }}></small>
                        <span class="{{ aSurveyInfo.class.saveformsurveydivdlabelspan }} sr-only text-danger asterisk" {{ aSurveyInfo.attr.saveformsurveydivdlabelspan }}>{{ gT("Mandatory") }}<span>
                    </label>

                    <div class='{{ aSurveyInfo.class.saveformsurveydivddiv }} col-sm-7 ' {{ aSurveyInfo.attr.saveformsurveydivddiv }}>
                        {% set htmlOptions = {
                                'id'          : 'savepass2',
                                'name'        : 'savepass2',
                                'class'       : 'form-control',
                                'required'    : true,
                            }
                        %}

                        {{ C.Html.passwordField(
                                'savepass2',
                                '',
                                (htmlOptions)
                        )  }}
                    </div>
                </div>

                <!-- Email -->
                <div class='{{ aSurveyInfo.class.saveformsurveydive }}  form-group ' {{ aSurveyInfo.attr.saveformsurveydive }}>
                    <label class='{{ aSurveyInfo.class.saveformsurveydivelabel }} control-label col-sm-3 ' {{ aSurveyInfo.attr.saveformsurveydivelabel }} >
                        {{ gT("Your email address:") }}
                    </label>
                    <div class='{{ aSurveyInfo.class.saveformsurveydivediv }} col-sm-7 ' {{ aSurveyInfo.attr.saveformsurveydivediv }}>

                        {% set htmlOptions = {
                                'id'          : 'saveemail',
                                'name'        : 'saveemail',
                                'class'       : 'form-control',
                            }
                        %}

                        {{ C.Html.emailField(
                                'saveemail',
                                '',
                                (htmlOptions)
                        )  }}
                    </div>
                </div>


                {% if aSurveyInfo.aSaveForm.aCaptcha.show %}
                    <!-- Captcha -->
                    <div class='{{ aSurveyInfo.class.saveformsurveydivf }} form-group ' {{ aSurveyInfo.attr.saveformsurveydivd }} >
                        <label class='{{ aSurveyInfo.class.saveformsurveydivflabel }} control-label col-sm-3 ' {{ aSurveyInfo.attr.saveformsurveydivdlabel }}  >
                            {{ gT("Security question:") }}
                        </label>
                        <div class='{{ aSurveyInfo.class.saveformsurveydivfdiv }} col-sm-7 ' {{ aSurveyInfo.attr.saveformsurveydivddiv }} >
                            <div class='{{ aSurveyInfo.class.saveformsurveydivfdivdiv }} input-group' {{ aSurveyInfo.attr.saveformsurveydivddivdiv }}>
                                <div class='{{ aSurveyInfo.class.saveformsurveydivfdivdivdiv }} ' {{ aSurveyInfo.attr.saveformsurveydivddivdivdiv }} >
                                    <img src='{{ aSurveyInfo.aSaveForm.aCaptcha.sImageUrl }}' {{ aSurveyInfo.attr.saveformsurveydivddivdivdivimg }}   />
                                </div>
                                <input class='{{ aSurveyInfo.class.saveformsurveydivfdivdivinput }}  form-control'  {{ aSurveyInfo.attr.saveformsurveydivfdivdivinput }} />
                            </div>
                        </div>
                    </div>
                {% endif %}

                <!-- save button -->
                <div class='{{ aSurveyInfo.class.saveformsurveydivg }} form-group' {{ aSurveyInfo.attr.saveformsurveydivg }}>
                    <div class='{{ aSurveyInfo.class.saveformsurveydivgdiv }}  col-sm-7 col-md-offset-3' {{ aSurveyInfo.attr.saveformsurveydivgdiv }}>
                        <button data-check-validity=1 {{ aSurveyInfo.attr.saveformsurveydivgdivbutton }}  class='{{ aSurveyInfo.class.saveformsurveydivgdivbutton }} btn btn-default' >
                            {{ gT("Save Now") }}
                        </button>
                    </div>
                </div>
            </div>


        <div class='{{ aSurveyInfo.class.saveformsurveydivh }}' {{ aSurveyInfo.attr.saveformsurveydivh }}>
            <div class="{{ aSurveyInfo.class.saveformsurveydivhdiv }} " {{ aSurveyInfo.attr.saveformsurveydivhdiv }}>
                <a href="{{ aSurveyInfo.surveyUrl }}" class="{{ aSurveyInfo.class.saveformsurveydivhdiva }}">{{ gT("Return to survey") }}</a>
            </div>
        </div>
    </div>

</form> <!-- main form -->
