Files
sterivein/templates/admin/default/profile-edit.html
2013-10-22 20:20:15 +02:00

452 lines
23 KiB
HTML

{extends file="admin-layout.tpl"}
{block name="page-title"}{intl l='Edit a profile'}{/block}
{block name="check-resource"}admin.configuration.profile{/block}
{block name="check-access"}update{/block}
{block name="main-content"}
{assign oder_tab {$smarty.get.tab|default:$smarty.post.tab|default:'data'}}
{assign asked_country {$smarty.get.country|default:{country ask="default" attr="id"}}}
<div class="profiles edit-profiles">
<div id="wrapper" class="container">
<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/profiles'}">{intl l="Profiles"}</a></li>
<li>{intl l='Editing profile'}</li>
</ul>
{loop type="profile" name="profile" id=$profile_id backend_context="1" lang=$edit_language_id}
<div class="row">
<div class="col-md-12 general-block-decorator clearfix">
<div class="lead clearfix">
<span class='label label-default pull-left'>{$CODE}</span>
</div>
<ul class="nav nav-tabs clearfix">
<li {if $oder_tab == 'data'}class="active"{/if}><a href="#data" data-tab-name="cart" data-toggle="tab"><span class="glyphicon glyphicon-shopping-cart"></span> {intl l="Description"}</a></li>
<li {if $oder_tab == 'resources'}class="active"{/if}><a href="#resources" data-tab-name="bill" data-toggle="tab"><span class="glyphicon glyphicon-list-alt"></span> {intl l="Resource access rights"}</a></li>
<li {if $oder_tab == 'modules'}class="active"{/if}><a href="#modules" data-tab-name="bill" data-toggle="tab"><span class="glyphicon glyphicon-list-alt"></span> {intl l="Module access rights"}</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane fade {if $oder_tab == 'data'}active in{/if}" id="data">
<div class="form-container">
{form name="thelia.admin.profile.modification"}
<form method="POST" action="{url path="/admin/configuration/profiles/save"}" {form_enctype form=$form} >
{include
file = "includes/inner-form-toolbar.html"
hide_submit_buttons = false
page_url = {url path="/admin/configuration/profiles/update/$profile_id" tab=data}
close_url = {url path="/admin/configuration/profiles"}
}
{* Be sure to get the product ID, even if the form could not be validated *}
<input type="hidden" name="profile_id" value="{$ID}" />
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path="/admin/configuration/profiles"}" />
{/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='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l=$label} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" required="required" title="{intl l='Title'}" placeholder="{intl l='Title'}" class="form-control" value="{if $error}{$value}{else}{if $IS_TRANSLATED == 1}{$TITLE}{/if}{/if}">
</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">{intl l=$label} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" title="{intl l='Chapo'}" placeholder="{intl l='Chapo'}" class="form-control" value="{if $error}{$value}{else}{if $IS_TRANSLATED == 1}{$CHAPO}{/if}{/if}">
</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">
{intl l=$label} :
<span class="label-help-block">{intl l="The detailed description."}</span>
</label>
<textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control wysiwyg">{if $error}{$value}{else}{if $IS_TRANSLATED == 1}{$DESCRIPTION}{/if}{/if}</textarea>
</div>
{/form_field}
{form_field form=$form field='postscriptum'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l=$label} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" title="{intl l='Postscriptum'}" placeholder="{intl l='Postscriptum'}" class="form-control" value="{if $error}{$value}{else}{if $IS_TRANSLATED == 1}{$POSTSCRIPTUM}{/if}{/if}">
</div>
{/form_field}
<div class="row">
<div class="col-md-12">
<div class="control-group">
<label>&nbsp;</label>
<div class="controls">
<p>{intl l='Profile 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>
</div>
</div>
</form>
{/form}
</div>
</div>
<div class="tab-pane fade {if $oder_tab == 'resources'}active in{/if}" id="resources">
{form name="thelia.admin.profile.resource-access.modification"}
<form method="POST" action="{url path="/admin/configuration/profiles/saveResourceAccess?tab=resources"}" {form_enctype form=$form} >
{form_hidden_fields form=$form}
{* Be sure to get the product ID, even if the form could not be validated *}
<input type="hidden" name="profile_id" value="{$ID}" />
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
<table class="table table-striped table-condensed table-left-aligned">
<caption>
{intl l="Manage resource rights"}
<button type="submit" class="btn btn-default btn-primary pull-right"><span class="glyphicon glyphicon-check"></span> {intl l="Save"}</button>
</caption>
<thead>
<tr>
<th rowspan="2">{intl l="Resource"}</th>
<th rowspan="2">{intl l="Title"}</th>
<th colspan="4" class="text-center">{intl l="Rights"}</th>
</tr>
<tr>
<th>{intl l="View"}</th>
<th>{intl l="Create"}</th>
<th>{intl l="Update"}</th>
<th>{intl l="Delete"}</th>
</tr>
</thead>
<tbody>
{form_tagged_fields form=$form tag='resources'}
{loop type="resource" name="resource-list" code=$attr_list.resource_code profile=$ID backend_context="1"}
<tr>
<td>{$CODE}</td>
<td>{$TITLE}</td>
<td>
<div class="make-switch switch-mini" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input name="{$name}" value="VIEW" type="checkbox" {if $VIEWABLE == 1}checked="checked"{/if}>
</div>
</td>
<td>
<div class="make-switch switch-mini" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input name="{$name}" value="CREATE" type="checkbox" {if $CREATABLE == 1}checked="checked"{/if}>
</div>
</td>
<td>
<div class="make-switch switch-mini" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input name="{$name}" value="UPDATE" type="checkbox" {if $UPDATABLE == 1}checked="checked"{/if}>
</div>
</td>
<td>
<div class="make-switch switch-mini" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input name="{$name}" value="DELETE" type="checkbox" {if $DELETABLE == 1}checked="checked"{/if}>
</div>
</td>
</tr>
{/loop}
{/form_tagged_fields}
</tbody>
<tfoot>
<tr>
<td colspan="7">
<button type="submit" class="btn btn-default btn-primary pull-right"><span class="glyphicon glyphicon-check"></span> {intl l="Save"}</button>
</td>
</tr>
</tfoot>
</table>
</form>
{/form}
</div>
<div class="tab-pane fade {if $oder_tab == 'modules'}active in{/if}" id="modules">
{form name="thelia.admin.profile.module-access.modification"}
<form method="POST" action="{url path="/admin/configuration/profiles/saveModuleAccess?tab=modules"}" {form_enctype form=$form} >
{form_hidden_fields form=$form}
{* Be sure to get the product ID, even if the form could not be validated *}
<input type="hidden" name="profile_id" value="{$ID}" />
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
<table class="table table-striped table-condensed table-left-aligned">
<caption>
{intl l="Manage module rights"}
<button type="submit" class="btn btn-default btn-primary pull-right"><span class="glyphicon glyphicon-check"></span> {intl l="Save"}</button>
</caption>
<thead>
<tr>
<th rowspan="2">{intl l="Module"}</th>
<th rowspan="2">{intl l="Title"}</th>
<th colspan="4" class="text-center">{intl l="Rights"}</th>
</tr>
<tr>
<th>{intl l="View"}</th>
<th>{intl l="Create"}</th>
<th>{intl l="Update"}</th>
<th>{intl l="Delete"}</th>
</tr>
</thead>
<tbody>
{form_tagged_fields form=$form tag='modules'}
{loop type="module" name="module-list" code=$attr_list.module_code profile=$ID backend_context="1"}
<tr>
<td>{$CODE}</td>
<td>{$TITLE}</td>
<td>
<div class="make-switch switch-mini" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input name="{$name}" value="VIEW" type="checkbox" {if $VIEWABLE == 1}checked="checked"{/if}>
</div>
</td>
<td>
<div class="make-switch switch-mini" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input name="{$name}" value="CREATE" type="checkbox" {if $CREATABLE == 1}checked="checked"{/if}>
</div>
</td>
<td>
<div class="make-switch switch-mini" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input name="{$name}" value="UPDATE" type="checkbox" {if $UPDATABLE == 1}checked="checked"{/if}>
</div>
</td>
<td>
<div class="make-switch switch-mini" data-on="success" data-off="danger" data-on-label="<i class='glyphicon glyphicon-ok'></i>" data-off-label="<i class='glyphicon glyphicon-remove'></i>">
<input name="{$name}" value="DELETE" type="checkbox" {if $DELETABLE == 1}checked="checked"{/if}>
</div>
</td>
</tr>
{/loop}
{/form_tagged_fields}
</tbody>
<tfoot>
<tr>
<td colspan="7">
<button type="submit" class="btn btn-default btn-primary pull-right"><span class="glyphicon glyphicon-check"></span> {intl l="Save"}</button>
</td>
</tr>
</tfoot>
</table>
</form>
{/form}
</div>
</div>
</div>
</div>
{/loop}
</div>
</div>
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/bootstrap-select/bootstrap-select.js'}
<script src='{$asset_url}'></script>
{/javascripts}
{javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{javascripts file='assets/js/main.js'}
<script src='{$asset_url}'></script>
{/javascripts}
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function() {
{if $taxUpdateError == true}
$('#tax_list_update_dialog').modal();
{/if}
$('.js-collapse').each(function(k, v) {
var h = $(v).data('collapse-height');
if( $(v).height() > h ) {
$(v).css('overflow', 'hidden').css('height', h + 'px');
} else {
$('[data-collapse-block=' + $(v).attr('id') + ']').hide();
}
});
$('.js-collapse-btn').click(function(e) {
e.preventDefault();
var block = $(this).data('collapseBlock');
$('#' + block).css('overflow', 'initial').css('height', 'initial');
$(this).unbind().remove();
});
$('.js-uncheck-all').click(function(e) {
e.preventDefault();
var selectId = $(this).data('uncheckSelect');
$('#' + selectId).selectpicker('deselectAll');
});
{literal}
$('#country-selector').change(function(e) {
$('#country-selector-form').submit();
});
// Cache jQuery Objects
var $group = $('#panel');
var $list = $('#panel-list');
// Build array of taxes rules
$('#apply-taxes-rules').click(function(){
var taxesRules = [],
index;
$('.drop-group', $group).each(function(i){
var $this = $(this);
index = i;
taxesRules[index] = [];
$('.drag', $this).each(function(j){
taxesRules[index][j] = [];
taxesRules[index][j] = $(this).data('id'); // retrieve with data
});
});
$('#tax_list').val(JSON.stringify(taxesRules));
});
// Default options for draggable
var dragOptions = {
cursor: 'move',
containment: "document",
opacity: 0.5,
revert: "invalid", // when not dropped, the item will revert back to its initial position
zIndex: 10
};
// Default options for sortabble
var sortOptions = {
cursor: 'move',
cancel: '.drop-message',
update: function( event, ui ){
// Check if we have an empty group
var $zone = $('.add-to-group', $group);
if($zone.size() > 1 && $(this).find('> div').size() == 0){ // Remove empty group only if we have more than 1 group
$(this).slideUp(function(){ $(this).remove(); });
}
}
};
// Default options for droppable
var dropOptions = {
accept: "#panel-list .draggable", // Controls which draggable elements are accepted
hoverClass: "over",
drop: function( event, ui ) {
var $drop = $(this);
if($(this).hasClass('create-group')){
// Check if we have already an empty group
var $empty_group = $group.find('.drop-group:not(:has(> div))');
if($empty_group.size() > 0){ // if yes (Use the first empty group)
$drop = $empty_group.filter(':first');
}else{ //if no (Create a new group)
$drop = $group.find('.drop-group:last-child').clone().appendTo($group.find('.panel-body'));
// Remove taxes
$drop.find('> div').remove();
// Make the new group droppable
$drop
.droppable(dropOptions)
.sortable(sortOptions);
}
}
$("<div></div>").addClass('drag').attr('data-id', ui.draggable.data('id')).text( ui.draggable.text()).appendTo( $drop );
ui.draggable.remove();
}
};
// Make the list of taxes draggable
$('.draggable', $list).draggable(dragOptions);
// let the drop-group be droppable & sortable, accepting the tax items
$('.droppable', $group)
.droppable(dropOptions)
.sortable(sortOptions);
$('.place .panel-body').sortable(sortOptions);
// let the gallery be droppable as well, accepting items from the trash
$('.remove-from-group', $list)
.droppable({
accept: "#panel .drag",
hoverClass: 'over',
drop: function( event, ui ) {
$("<div></div>").addClass('draggable').text( ui.draggable.text() ).attr('data-id', ui.draggable.data('id')).draggable(dragOptions).appendTo( $list.find('.panel-body') );
ui.draggable.remove();
}
});
{/literal}
});
</script>
{/block}