mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 14:03:27 +00:00
74 lines
2.7 KiB
Twig
74 lines
2.7 KiB
Twig
<div class="header">
|
||
<h1>{% trans 'Upload a "csv" file for users creation' %}</h1>
|
||
</div>
|
||
|
||
{% if app['request'].query.get('error') is not none %}
|
||
{% set error = app['request'].query.get('error') %}
|
||
<div class="alert alert-error">
|
||
<button class="close" data-dismiss="alert" type="button">×</button>
|
||
{% if error == 'file-invalid' %}
|
||
{% trans 'An error occured while upload the file. Please retry' %}
|
||
{% elseif error == 'row-login' %}
|
||
{% trans 'Row "login" is missing, script has stopped' %}
|
||
{% elseif error == 'row-pwd' %}
|
||
{% trans 'Row "password" is missing, script has stopped' %}
|
||
{% elseif error == 'no-user' %}
|
||
{% trans 'The file does not contains any user to add' %}
|
||
{% endif %}
|
||
</div>
|
||
{% endif %}
|
||
|
||
{% if errors is defined and errors is not none and errors|length > 0 %}
|
||
<div class="alert alert-error">
|
||
<button class="close" data-dismiss="alert" type="button">×</button>
|
||
<ul class="unstyled">
|
||
{% for error in errors %}
|
||
<li>{{ error }}</li>
|
||
{% endfor%}
|
||
</ul>
|
||
</div>
|
||
{% endif %}
|
||
|
||
<div>
|
||
<div class="well well-small">
|
||
<a href="/admin/users/import/example/csv/"> <i class="icon-share"></i> {% trans 'You can download an example by clicking here' %}</a>
|
||
</div>
|
||
<div class="well well-small">
|
||
<a href="/admin/users/import/example/rtf/"> <i class="icon-share"></i> {% trans 'You can download the documentation here' %}</a>
|
||
</div>
|
||
<span class="label" style="display:inline-block;" >
|
||
<i class="icon-plus icon-white"></i>
|
||
<span>{% trans 'Select a file' %}</span>
|
||
<input id="fileupload" type="file" name="files" data-url="/admin/users/import/file/" accept="text/csv, text/rtf">
|
||
</span>
|
||
<a href="/admin/users/search/" class="btn ajax">{% trans 'boutton::retour' %}</a>
|
||
</div>
|
||
|
||
<script>
|
||
$(function () {
|
||
$('#fileupload').fileupload({
|
||
dataType: 'html',
|
||
add: function(e, data) {
|
||
if( ! /(\.|\/)(csv|rtf)$/i.test(data.files[0].type)) {
|
||
{% set supported_file_types = ['csv', 'rtf']|join(' | ') %}
|
||
alert("{% trans %} Invalid file type, only ({{ supported_file_types }}) file formats are supported {% endtrans %}");
|
||
|
||
return false;
|
||
}
|
||
|
||
data.submit();
|
||
},
|
||
submit: function(e, data) {
|
||
$('#right-ajax').empty().addClass('loading');
|
||
},
|
||
done: function (e, data) {
|
||
$('#right-ajax').removeClass('loading').html(data.result);
|
||
enableForms($('#right-ajax form:not(.no-ajax)'));
|
||
|
||
$.each($('#right-ajax a'),function(i, el){
|
||
enableLink($(el));
|
||
});
|
||
}
|
||
});
|
||
});
|
||
</script> |