{extends file="admin-layout.tpl"}

{block name="no-return-functions"}
    {$admin_current_location = 'configuration'}
{/block}

{block name="page-title"}{intl l='Edit a system variable'}{/block}

{block name="check-resource"}admin.configuration.variable{/block}
{block name="check-access"}update{/block}

{block name="main-content"}
<div class="variables edit-variable">

    <div id="wrapper" class="container">

        {loop name="config_edit" type="config" hidden="*" id="$variable_id" backend_context="1" lang="$edit_language_id"}

        <ul class="breadcrumb">
			<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
            <li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a></li>
            <li><a href="{url path='/admin/configuration/variables'}">{intl l="System variables"}</a></li>
            <li>{intl l='Editing variable "%name"' name={$NAME}}</li>
        </ul>

		{hook name="variables-edit.top" variable_id=$variable_id}

		<div class="row">
			<div class="col-md-12 general-block-decorator">
				<div class="row">

					<div class="col-md-12 title title-without-tabs">
					   {intl l="Edit variable %name" name={$NAME}}
					</div>

                    <div class="form-container">
                         <div class="col-md-12">
						    {form name="thelia.admin.config.modification"}
						    <form method="POST" action="{url path='/admin/configuration/variables/save'}" {form_enctype}>
                                <fieldset>
                                    {* Be sure to get the variable ID, even if the form could not be validated *}
                                    <input type="hidden" name="variable_id" value="{$variable_id}" />

                                    {include file="includes/inner-form-toolbar.html" close_url="{url path='/admin/configuration/variables'}"}

							        {form_hidden_fields}

							        {form_field field='success_url'}
							        <input type="hidden" name="{$name}" value="{url path='/admin/configuration/variables'}" />
							        {/form_field}

							        {* We do not allow creation of hidden variables *}

                                    {form_field field='id'}
                                    <input type="hidden" name="{$name}" value="{$value}" />
                                    {/form_field}

			                        {form_field field='hidden'}
			                        <input type="hidden" name="{$name}" value="{$value}" />
			                        {/form_field}

			                        {form_field field='locale'}
			                        <input type="hidden" name="{$name}" value="{$edit_language_locale}" />
			                        {/form_field}

						            {if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}

									{form_field field='name'}
						            <div class="form-group {if $error}has-error{/if}">
    									<label for="{$label_attr.for}" class="control-label">{$label} : </label>
					                    <input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value}" title="{intl l='Variable name'}" placeholder="{intl l='Variable name'}" class="form-control">
						            </div>
						            {/form_field}

									{form_field field='value'}
						            <div class="form-group {if $error}has-error{/if}">
    									<label for="{$label_attr.for}" class="control-label">{$label} : </label>
						                <input type="text" id="{$label_attr.for}" name="{$name}" value="{$value}" title="{intl l='Variable value'}" placeholder="{intl l='Variable value'}" class="form-control">
						            </div>
						            {/form_field}

									{form_field field='secured'}
			                        <div class="checkbox {if $error}has-error{/if}">
										<label>
	                                        <input type="checkbox" name="{$name}" value="1" {if $value == 1}checked="checked"{/if}>
	                                        {$label}
										</label>
			                        </div>
			                        {/form_field}

                                    {include file="includes/standard-description-form-fields.html"}

                                    <div class="control-group">
                                        <div class="controls">
                                            <p>{intl l='Variable created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}</p>
                                        </div>
                                    </div>

                                </fieldset>
							</form>
							{/form}
						</div>
					</div>
				</div>
			</div>

		</div>

		{hook name="variables-edit.bottom" variable_id=$variable_id}

		{/loop}

        {elseloop rel="config_edit"}
        <div class="row">
            <div class="col-md-12">
                <div class="alert alert-error">
                    {intl l="Sorry, variable ID=%id was not found." id={$variable_id}}
                </div>
            </div>
        </div>
        {/elseloop}

    </div>
</div>
{/block}

{block name="javascript-last-call"}
    {hook name="variable.edit-js" location="variable-edit-js" }
    {hook name="wysiwyg.js" location="wysiwyg-variable-edit-js" }
{/block}