]> git.agnieray.net Git - galette.git/blob - galette/templates/default/import.tpl
Add CSRF Middleware
[galette.git] / galette / templates / default / import.tpl
1 {extends file="page.tpl"}
2
3 {block name="content"}
4 <p class="center">
5 <a
6 href="{path_for name="importModel"}"
7 class="button"
8 >
9 <i class="fas fa-cogs" aria-hidden="true"></i>
10 {_T string="Configure import model"}
11 </a>
12 </p>
13 <form class="form" action="{path_for name="doImport"}" method="post">
14 <fieldset>
15 <legend class="ui-state-active ui-corner-top">{_T string="Existing files"}</legend>
16 <div class="warningbox">
17 {_T string="Warning: Don't forget to backup your current database."}
18 </div>
19 <div>
20 {if $existing|@count gt 0}
21 <p>{_T string="The following files seems ready to import on the disk:"}</p>
22 <table class="listing">
23 <thead>
24 <tr>
25 <th>{_T string="Name"}</th>
26 <th>{_T string="Date"}</th>
27 <th>{_T string="Size"}</th>
28 <th class="actions_row"></th>
29 </tr>
30 </thead>
31 <tbody>
32 {foreach item=import from=$existing name=existing_list}
33 <tr class="{if $smarty.foreach.existing_list.iteration % 2 eq 0}even{else}odd{/if}">
34 <td data-scope="row">
35 <input type="radio" name="import_file" id="file{$smarty.foreach.existing_list.iteration}" value="{$import.name}"{if isset($import_file) and $import_file eq $import.name} checked="checked"{/if}/>
36 <label for="file{$smarty.foreach.existing_list.iteration}">{$import.name}</label> (<a href="{path_for name="getCsv" data=["type" => "import", "file" => $import.name]}">{_T string="see"}</a>)
37 </td>
38 <td data-title="{_T string="Date"}">
39 {$import.date}
40 </td>
41 <td data-title="{_T string="Size"}">
42 {$import.size}
43 </td>
44 <td class="actions_row">
45 <a
46 href="{path_for name="removeCsv" data=["type" => "import", "file" => $import.name]}"
47 class="delete tooltip"
48 >
49 <i class="fas fa-trash"></i>
50 <span class="sr-only">{_T string="Remove '%file' from disk" pattern="/%file/" replace=$import.name}</span>
51 </a>
52 </td>
53 </tr>
54 {/foreach}
55 </tbody>
56 </table>
57 <div class="button-container">
58 <label for="dryrun" title="{_T string="Run the import process, but do *not* store anything in the database"}">{_T string="Dry run"}</label>
59 <input type="checkbox" name="dryrun" id="dryrun" value="1"{if isset($dryrun) and $dryrun eq true} checked="checked"{/if}/>
60 <button type="submit" name="import" id="import">
61 <i class="fas fa-file-import"></i>
62 {_T string="Import"}
63 </button>
64 {include file="forms_types/csrf.tpl"}
65 </div>
66 {else}
67 <p>{_T string="No import file actually exists."}<br/>{_T string="Use upload form below to send a new file on server, or copy it directly in the imports directory."}</p>
68 {/if}
69 </div>
70 </fieldset>
71 </form>
72 <form class="form" action="{path_for name="uploadImportFile"}" method="post" enctype="multipart/form-data">
73 <fieldset>
74 <legend class="ui-state-active ui-corner-top">{_T string="Upload new file"}</legend>
75 <div>
76 <p>
77 <label for="new_file">{_T string="Select a file:"}</label>
78 <input class="labelalign" type="file" name="new_file" accept="text/csv" id="new_file"/>
79 </p>
80 <div class="button-container">
81 <button type="submit" name="upload" id="upload">
82 <i class="fas fa-upload" aria-hidd="true"></i>
83 {_T string="Upload file"}
84 </button>
85 {include file="forms_types/csrf.tpl"}
86 </div>
87 </div>
88 </fieldset>
89 </form>
90 {/block}
91
92 {block name="javascripts"}
93 <script type="text/javascript">
94 $(function() {
95 _collapsibleFieldsets();
96 //bind import click to check if one is selected
97 $('#import').on('click', function(){
98 if ( $('input[name=import_file]:checked').length > 0 ) {
99 return true;
100 } else {
101 var _el = $('<div id="pleaseselect" title="{_T string="No file selected" escape="js"}">{_T string="Please make sure to select one file to import." escape="js"}</div>');
102 _el.appendTo('body').dialog({
103 modal: true,
104 buttons: {
105 Ok: function() {
106 $(this).dialog( "close" );
107 }
108 },
109 close: function(event, ui){
110 _el.remove();
111 }
112 });
113 return false;
114 }
115 });
116
117 $('#upload').click(function(){
118 var _selected = $('#new_file')[0].files.length;
119 if ( _selected == 0 ) {
120 var _el = $('<div id="pleaseupload" title="{_T string="No file to upload" escape="js"}">{_T string="Please make sure to select one file to upload." escape="js"}</div>');
121 _el.appendTo('body').dialog({
122 modal: true,
123 buttons: {
124 Ok: function() {
125 $(this).dialog( "close" );
126 }
127 },
128 close: function(event, ui){
129 _el.remove();
130 }
131 });
132 return false;
133 } else {
134 return true;
135 }
136 });
137 });
138 {include file="js_removal.tpl"}
139 </script>
140 {/block}