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

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

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

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

{block name="main-content"}
    <div class="currencies edit-currency">

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

            {loop name="currency_edit" type="currency" id="$currency_id" backend_context="1" visible="*" 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/currencies'}">{intl l="Currencies"}</a></li>
                    <li>{intl l='Editing currency "%name"' name="{$NAME}"}</li>
                </ul>

			{hook name="currency-edit.top" currency_id=$currency_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 currency "%name"' name={$NAME}}
        					</div>

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

        						    {form name="thelia.admin.currency.modification"}
        						    	<form method="POST" action="{url path='/admin/configuration/currencies/save'}" {form_enctype} class="clearfix">

        	                                {* Be sure to get the currency ID, even if the form could not be validated *}
        	                                <input type="hidden" name="currency_id" value="{$currency_id}" />

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

        						        	{form_hidden_fields}

        						        	{form_field field='success_url'}
        						        		<input type="hidden" name="{$name}" value="{url path='/admin/configuration/currencies'}" />
        						        	{/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}

        	                                <div class="col-md-6">

												{render_form_field field='name'}

        										{form_field field='code'}
        		                                    <div class="form-group {if $error}has-error{/if}">
														<label for="{$label_attr.for}" class="control-label">
															{$label}{if $required} *{/if}
														</label>
                                                        <input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value}" placeholder="{$label_attr.placeholder}" class="form-control">
                                                        <span class="help-block">
                                                            <a title="{$label_attr.help}" href="http://fr.wikipedia.org/wiki/ISO_4217" target="_blank">{$label_attr.help}</a>
                                                        </span>
        		                                    </div>
        		                               	{/form_field}

        	                                </div>

                                            <div class="col-md-6">
                                                {render_form_field field='symbol'}

												{form_field field='format'}
													<div class="form-group {if $error}has-error{/if}">
														<label for="{$label_attr.for}" class="control-label">
															{$label}{if $required} *{/if}
														</label>
														<input type="text" size="10" id="{$label_attr.for}" required="required" name="{$name}" value="{$value}" placeholder="{$label_attr.placeholder}" class="form-control">
                                                        <span class="help-block">
															{$label_attr.help}
                                                        </span>
													</div>
												{/form_field}

												{render_form_field field='rate'}
                                            </div>

                                        </form>
        							{/form}

        						</div>
        					</div>

        				</div>
        			</div>

        		</div>

			{hook name="currency-edit.bottom" currency_id=$currency_id}

    		{/loop}

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

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

{block name="javascript-last-call"}
    {hook name="currency.edit-js" location="currency-edit-js" currency_id={$currency_id} }
{/block}