Merge branch 'b-3.6.1' of ../kivitendo-erp_20220811
[kivitendo-erp.git] / templates / webpages / file / list.html
diff --git a/templates/webpages/file/list.html b/templates/webpages/file/list.html
new file mode 100644 (file)
index 0000000..2868d4f
--- /dev/null
@@ -0,0 +1,149 @@
+[%- USE LxERP -%][% USE L %]
+[% USE T8 %]
+[% USE Base64 %]
+[% USE HTML %]
+[%- IF ! json %]
+ <div id="[% file_type %]_list_[% object_type %]">
+[%- END %]
+<div class="listtop">[% title %]</div>
+
+<div style="padding-bottom: 15px">
+ [%- SET can_rename = 0 %]
+ [%- FOREACH source = SOURCES %]
+  <table style="width: 100%" >
+   <thead>
+    <tr><th class="listheading" colspan="[% IF file_type == 'image' %]8[% ELSE %]6[% END %]">[% source.title %]</th></tr>
+    <tr>
+     [%- SET checkname = source.chk_action %]
+     [%- IF is_global %]
+      [%- SET checkname = object_type _ '_' _ source.chk_action %]
+     [%- END %]
+     [%- IF edit_attachments %]
+      <script type="text/javascript">
+       <!--
+        $(function() {
+         $('#[% checkname %]_checkall').checkall('INPUT[name="[% checkname %][]"]');
+        });
+       -->
+      </script>
+      <th class="listheading" width="3%">[% L.checkbox_tag(checkname _ '_checkall') %]</th>
+      <th class="listheading" width="7%">[% source.chkall_title %]</th>
+     [%- END %]
+     <th class="listheading" width="2%"><b>[%  LxERP.t8('Version') %]</b></th>
+     <th class="listheading" width="15%"><b>[%  LxERP.t8('Date') %]</b></th>
+     <th class="listheading" width="20%"><b>[%  source.file_title %]</b></th>
+     [%- IF file_type == 'image' %]
+      <th class="listheading" width="15%"><b>[%  LxERP.t8('Title') %]</b></th>
+      <th class="listheading" width="10%">
+       <b>[%  LxERP.t8('ImagePreview') %]</b>
+      </th>
+      <th class="listheading" width="30%"><b>[%  LxERP.t8('Description') %]</b></th>
+     [%- ELSE %]
+      <th class="listheading" width="40%"><b>[%  LxERP.t8('ImagePreview') %]</b></th>
+     [%- END %]
+    </tr>
+   </thead>
+
+   <tbody>
+    [%- FOREACH file = source.files %]
+     [%- is_other_version = 1 IF last_id == file.id %]
+     [%- last_id = file.id %]
+     [%- IF !is_other_version %]
+      [%- row_cnt = row_cnt + 1 %]
+      <tr class="listrow[% row_cnt % 2 %]">
+     [%- ELSE %]
+      <tr class="[% 'version_row_' _ file.id %] listrow[% row_cnt % 2 %] hidden">
+     [%- END %]
+      [%- IF edit_attachments %]
+       <td>[%- L.checkbox_tag(checkname _ '[]', 'value'=file.id _ '_' _ file.version, 'class'=checkname) %]</td>
+       <td></td>
+      [%- END %]
+      <td align="right" [%- IF file.version_count > 1 && !is_other_version %] class="cursor-pointer" onclick="kivi.File.toggle_versions('[% file.id %]')"[%- END %]>
+       [%- IF file.version_count > 1 && !is_other_version %]<span id="[% 'version_toggle_' _ file.id %]">⏷ </span>[% END %]
+       [% file.version _ '/' _ file.version_count %]
+       [% L.hidden_tag("version[]", file.version) %]
+      </td>
+      <td>[% file.mtime_as_timestamp_s %]</td>
+      <td>
+       <a href="controller.pl?action=File/download&id=[% file.id %][%- IF file.version %]&version=[%- file.version %][%- END %]">
+        <span id="[% "filename_" _ file.id %][%- IF file.version %]_[% file.version %][%- END %]">[% file.file_name %]</span>
+       </a>
+      </td>
+      [%- IF file_type == 'image' %]
+       <td>[% file.title %]</td>
+       <td>
+        <img src="controller.pl?action=File/download&id=[% file.id %][%- IF file.version %]&version=[%- file.version %][%- END %]" alt="[% file.title %]" width="64px">
+       </td>
+       <td>[% file.description %]</td>
+      [%- ELSE %]
+       <td align="left">
+        [%- IF file.thumbnail %]
+         <div class="overlay_div">
+          <img id="thumb_[% file.id %]" class="thumbnail"
+               data-file-id="[% file.id %]" data-file-version="[% file.version %]"
+               src="data:[% HTML.escape(file.thumbnail.thumbnail_img_content_type) %];base64,[% file.thumbnail.thumbnail_img_content.encode_base64 %]"
+               alt="[% file.file_name %]">
+          <img id="enlarged_thumb_[% file.id %][% IF file.version %]_[% file.version %][% END %]" class="overlay_img" style="display:none;"
+               data-file-id="[% file.id %]" data-file-version="[% file.version %]">
+         </div>
+        [%- ELSE %]
+         -
+        [%- END %]
+       </td>
+      [%- END %]
+     </tr>
+    [%- END # FOREACH file %]
+   </tbody>
+  </table>
+
+  <div>
+   [%- IF edit_attachments %]
+    [%- IF source.can_import %]
+     [% L.button_tag("kivi.File.unimport(" _ object_id _ ",'" _ object_type _ "','" _ file_type _ "','" _ checkname _ "');",source.chk_title) %]
+    [%- ELSE %]
+     [%- IF source.can_delete %]
+      [% L.button_tag("kivi.File.delete("   _ object_id _ ",'" _ object_type _ "','" _ file_type _ "','" _ checkname _ "'," _ is_global _ ");",  source.chk_title) %]
+     [%- END %]
+    [%- END %]
+   [%- END %]
+   [%- IF source.can_rename %]
+    [%- can_rename = 1 %]
+    [% L.button_tag("kivi.File.rename(" _ object_id _ ",'" _ object_type _ "','" _ file_type _ "','" _ checkname _ "'," _ is_global _ ");",  source.rename_title ) %]
+   [%- END %]
+   [%- IF source.can_import %]
+    [% L.button_tag("kivi.File.import("   _ object_id _ ",'" _ object_type _ "','" _ file_type _ "','" _ source.name _ "','" _ source.path _"');",  source.import_title ) %]
+   [%- END %]
+   [%- IF source.can_upload %]
+    [% L.button_tag("kivi.File.upload(" _ object_id _ ",'" _ object_type _ "','" _ file_type _ "','" _ source.upload_title _ "'," _ is_global _ ");", source.upload_title ) %]
+    <span class="upload_drop_zone"
+          data-object-type="[% object_type %]"
+          data-object-id="[% object_id %]"
+          data-file-type="[% file_type %]"
+          data-is-global="[% is_global %]"
+          data-maxsize="[% INSTANCE_CONF.get_doc_max_filesize %]">
+      [% 'Drag and drop files here' | $T8 %]
+    </span>
+   [%- END %]
+  </div>
+ [%- END # FOREACH source %]
+ <div></div>
+ <div>
+  [% L.button_tag("kivi.File.update(" _ object_id _ ",'" _ object_type _ "','" _ file_type _ "'," _ is_global _ ");", LxERP.t8('Update')) %]
+ </div>
+</div>
+
+[%- IF ! json %]
+ </div>
+ [%- UNLESS is_global %]
+  [%- IF can_rename %]
+   [% INCLUDE 'file/rename_dialog.html' -%]
+  [%- END %]
+ [%- END %]
+[%- END %]
+
+<script>
+  $(function() {
+    kivi.File.list_div_id = "[% file_type %]_list_[% object_type %]";
+    kivi.File.init();
+  });
+</script>