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

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

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

{block name="main-content"}
    <div class="countries edit-country">

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

            {loop name="country_edit" type="country" id="$country_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/countries'}">{intl l="Countries"}</a></li>
                    <li>{intl l='Editing country "%name"' name="{$TITLE}"}</li>
                </ul>

        		<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 country "%name"' name="{$TITLE}"}
        					</div>

                            <div class="form-container">
                                <div class="col-md-12">

        						    {form name="thelia.admin.country.modification"}
        						    	<form method="POST" action="{url path="/admin/configuration/country/save/{$ID}"}" {form_enctype form=$form} class="clearfix">
                                            {include
                                                file = "includes/inner-form-toolbar.html"
                                                hide_submit_buttons = false

                                                page_url  = {url path="/admin/configuration/country/update/$ID"}
                                                close_url = {url path="/admin/configuration/countries"}
                                            }
                                            <div class="row">
            	                                <div class="col-md-12">
                                                    {* Be sure to get the country ID, even if the form could not be validated *}
                	                                <input type="hidden" name="country_id" value="{$country_id}" />

                						        	{form_hidden_fields form=$form}

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

                                                    {form_field form=$form 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 form=$form field='area'}
                                                        <div class="form-group {if $error}has-error{/if}">
                                                            <label for="{$label_attr.for}" class="control-label">{$label} : </label>
                                                            <select name="{$name}" id="{$label_attr.for}" class="form-control">
                                                                <option value="{$ID}">{$TITLE}</option>
                                                            </select>
                                                        </div>
                                                    {/form_field}

                                                    {form_field form=$form field='isocode'}
                                                        <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}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='ISO Code'}">
                                                        </div>
                                                    {/form_field}

                                                    {form_field form=$form field='isoalpha2'}
                                                        <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}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Alpha code 2'}">
                                                        </div>
                                                    {/form_field}

                                                    {form_field form=$form field='isoalpha3'}
                                                        <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}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Alpha code 3'}">
                                                        </div>
                                                    {/form_field}

                                                    {form_field form=$form field='title'}
                                                        <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}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Country title'}">
                                                        </div>
                                                    {/form_field}
                                                    {form_field form=$form field='chapo'}
                                                        <div class="form-group {if $error}has-error{/if}">
                                                            <label for="{$label_attr.for}" class="control-label">{$label} : </label>
                                                            <textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{$label}" placeholder="{intl l='Country short description'}">{$value}</textarea>
                                                        </div>
                                                    {/form_field}
                                                    {form_field form=$form field='description'}
                                                        <div class="form-group {if $error}has-error{/if}">
                                                            <label for="{$label_attr.for}" class="control-label">{$label} : </label>
                                                            <textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{$label}" placeholder="{intl l='Country description'}">{$value}</textarea>
                                                        </div>
                                                    {/form_field}
                                                </div>
                                        </form>
        							{/form}

        						</div>
        					</div>

        				</div>
        			</div>

        		</div>

    		{/loop}

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

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

{block name="javascript-last-call"}
    {module_include location='country-edit-js'}
{/block}