uploads.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {% extends base %}
  2. {% block content %}
  3. {% import "macros/action_icons_static.html" as icons with context %}
  4. <span class="title"><h2>{% block title %}Capture Record Uploads{% endblock %}</h2></span>
  5. <div>Manage documents for <span style="font-weight: bold;">{{ names }}</span>.</div>
  6. <div class="content-container content">
  7. {% if record_qualifications %}
  8. <article>
  9. <h3>Current Qualifications on Record - for reference</h3>
  10. <ul>
  11. {% for qualification in record_qualifications %}
  12. <li>{{ qualification.v_qualification_name }}&nbsp;{{ qualification.d_acquired|date_format }}</li>
  13. {% endfor %}
  14. </ul>
  15. </article>
  16. {% endif %}{# end of checking for existing qualification records #}
  17. <article>
  18. <h3>Upload Documents</h3>
  19. <div><button type="button" id="btn_upload_document">
  20. {{ icons.add_svg(s_label="upload document") }}
  21. Upload Document
  22. </button></div>
  23. {% if document_uploads %}
  24. <div class="table-container">
  25. <table class="data-table" id="tbl_uploads">
  26. <thead>
  27. <tr>
  28. <th>File Name</th><th>Type</th><th>Matching Qualification></th><th>Description</th><th style="font-size: smaller;">Actions</th>
  29. </tr>
  30. </thead>
  31. <tbody>
  32. {% for upload in document_uploads %}
  33. <tr>
  34. <td><a href="{{ url_for("main.download_upload", i_upload=upload.id, bl_download=False) }}" class="a_view_upload" target="_blank">{{ icons.view_svg(s_label="view upload") }}</a>&nbsp;{{ upload.v_filename }}</td><td>{{ upload.si_upload_type }}</td><td>{{ upload.v_qualification_name }}</td><td>{{ upload.v_description }}</td><td><a href="#{{ upload.id }}" class="a_remove_upload">{{ icons.delete_svg(s_label="remove upload") }}</a></td>
  35. </tr>
  36. {% endfor %}{# end of looping through existing document uploads #}
  37. </tbody>
  38. </table><!-- end of tbl_uploads -->
  39. </div><!-- end of div.table-container -->
  40. {% endif %}{# end of checking for existing document uploads #}
  41. </article>
  42. </div><!-- end of div.content -->
  43. {% from "macros/dialog.html" import dlg_prep with context %}
  44. {{ dlg_prep(["dlg_upload"]) }}
  45. {# dlg divs below #}
  46. <div id="dlg_upload" aria-labeledby="spn_upload">
  47. <span id="spn_upload">Upload document</span><br>
  48. <form action="{{ url_for("main.uploads", i_record=record_id) }}" method="post" enctype="multipart/form-data" id="frm_upload">
  49. {{ upload_form.csrf_token }}
  50. <ul>
  51. <li>{{ upload_form.sel_upload_type.label }}&nbsp;{{ upload_form.sel_upload_type }}</li>
  52. <li>{{ upload_form.sel_match.label }}&nbsp;{{ upload_form.sel_match }}</li>
  53. <li>{{ upload_form.fil_upload_document.label }}&nbsp;{{ upload_form.fil_upload_document }}<br></li>
  54. <li>{{ upload_form.txt_description.label }}<br>
  55. {{ upload_form.txt_description }}</li>
  56. </ul>
  57. <input type="submit" name="btn_upload" value="Upload document">
  58. </form>
  59. </div><!-- end of dlg_upload -->
  60. <script type="text/javascript">
  61. $(document).ready( function() {
  62. try {
  63. var s_dlg_upload = $("#dlg_upload").html();
  64. $("#btn_upload_document").click( function(event) {
  65. event.preventDefault();
  66. $("#dlg_upload").html(s_dlg_upload);
  67. $("#dlg_upload").redraw();
  68. $("#dlg_upload").dialog("open");
  69. });// end of #btn_upload_document click event
  70. $("#tbl_uploads").on("click", ".a_remove_upload", function(event) {
  71. event.preventDefault();
  72. var s_id = String($(this).attr("href")).replace("#", "");
  73. var bl_confirm = confirm("Are you sure?");
  74. if (bl_confirm) {
  75. $("#hid_remove_upload_id").val(s_id);
  76. document.getElementById("frm_remove_upload").submit();
  77. }// end of confirmation check
  78. });// end of click event on .a_remove_upload inside tbl_uploads
  79. do_alert("waiting...");
  80. } catch(e) {
  81. var s_err = String(e.name) + "\nmessage:" + String(e.message);
  82. s_err = (typeof(e.lineNumber)!="undefined") ? s_err + "\nline:" + String(e.lineNumber) : s_err;
  83. alert("Error! " + s_err);
  84. }//end of catch
  85. });// end of additional document ready
  86. </script>
  87. <form action="{{ url_for("main.uploads", i_record=record_id) }}" method="post" id="frm_remove_upload">
  88. {{ remove_upload_form.csrf_token }}
  89. {{remove_upload_form.hid_remove_upload_id }}
  90. </form>
  91. {% endblock %}