uploads.html 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. {% extends base %}
  2. {% block content %}
  3. {% import "macros/action_icons_static.html" as icons %}
  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">
  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><a href="#" id="a_upload_document">Upload Document</a></div>
  20. {% if document_uploads %}
  21. <table class="multirow" id="tbl_uploads">
  22. <thead>
  23. <tr>
  24. <th>File Name</th><th>Type</th><th>Matching Qualification></th><th>Description</th><th style="font-size: smaller;">[Actions]</th>
  25. </tr>
  26. </thead>
  27. <tbody>
  28. {% for upload in document_uploads %}
  29. <tr>
  30. <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>
  31. </tr>
  32. {% endfor %}{# end of looping through existing document uploads #}
  33. </tbody>
  34. </table>
  35. {% endif %}{# end of checking for existing document uploads #}
  36. </article>
  37. </div><!-- end of div.content -->
  38. {% from "macros/dialog.html" import dlg_prep with context %}
  39. {{ dlg_prep(["dlg_upload"]) }}
  40. {# dlg divs below #}
  41. <div id="dlg_upload" aria-labeledby="spn_upload">
  42. <span id="spn_upload">Upload document</span><br>
  43. <form action="{{ url_for("main.uploads", i_record=record_id) }}" method="post" enctype="multipart/form-data" id="frm_upload">
  44. {{ upload_form.csrf_token }}
  45. <ul>
  46. <li>{{ upload_form.sel_upload_type.label }}&nbsp;{{ upload_form.sel_upload_type }}</li>
  47. <li>{{ upload_form.sel_match.label }}&nbsp;{{ upload_form.sel_match }}</li>
  48. <li>{{ upload_form.fil_upload_document.label }}&nbsp;{{ upload_form.fil_upload_document }}<br></li>
  49. <li>{{ upload_form.txt_description.label }}<br>
  50. {{ upload_form.txt_description }}</li>
  51. </ul>
  52. <input type="submit" name="btn_upload" value="Upload document">
  53. </form>
  54. </div><!-- end of dlg_upload -->
  55. <script type="text/javascript">
  56. $(document).ready( function() {
  57. try {
  58. var s_dlg_upload = $("#dlg_upload").html();
  59. $("#a_upload_document").click( function(event) {
  60. event.preventDefault();
  61. $("#dlg_upload").html(s_dlg_upload);
  62. $("#dlg_upload").redraw();
  63. $("#dlg_upload").dialog("open");
  64. });// end of #a_upload_document click event
  65. $("#tbl_uploads").on("click", ".a_remove_upload", function(event) {
  66. event.preventDefault();
  67. var s_id = String($(this).attr("href")).replace("#", "");
  68. var bl_confirm = confirm("Are you sure?");
  69. if (bl_confirm) {
  70. $("#hid_remove_upload_id").val(s_id);
  71. document.getElementById("frm_remove_upload").submit();
  72. }// end of confirmation check
  73. });// end of click event on .a_remove_upload inside tbl_uploads
  74. do_alert("waiting...");
  75. } catch(e) {
  76. var s_err = String(e.name) + "\nmessage:" + String(e.message);
  77. s_err = (typeof(e.lineNumber)!="undefined") ? s_err + "\nline:" + String(e.lineNumber) : s_err;
  78. alert("Error! " + s_err);
  79. }//end of catch
  80. });// end of additional document ready
  81. </script>
  82. <form action="{{ url_for("main.uploads", i_record=record_id) }}" method="post" id="frm_remove_upload">
  83. {{ remove_upload_form.csrf_token }}
  84. {{remove_upload_form.hid_remove_upload_id }}
  85. </form>
  86. {% endblock %}