templates/Documents/viewDocument.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}
  3.     OceanExpert | Document
  4. {% endblock %}
  5. {% block stylesheets %}
  6.     <link rel="stylesheet" type="text/css" href="{{ asset('css/navbar-login.css') }}">
  7.     <link rel="stylesheet" type="text/css" href="{{ asset('css/bootstrap.min.css') }}">
  8.     <link rel="stylesheet" type="text/css" href="{{ asset('css/font-awesome.min.css') }}">
  9.     <link rel="stylesheet" type="text/css" href="{{ asset('css/ionicons.min.css') }}">
  10.     <link rel="stylesheet" type="text/css" href="{{ asset('css/AdminLTE.min.css') }}">
  11.     <link rel="stylesheet" type="text/css" href="{{ asset('css/style.css') }}">
  12.     <link rel="stylesheet" type="text/css" href="{{ asset('css/square/blue.css') }}">
  13.     <link rel="stylesheet" type="text/css" href="{{ asset('css/jquery-confirm.min.css') }}">
  14.     <style>
  15.         .files{
  16.             margin-top: 15px;
  17.         }
  18.         .bg-info{
  19.             padding: 20px;
  20.         }
  21.         .addDoclist{
  22.             width:550px;}
  23.     </style>
  24. {% endblock %}
  25. {% block body %}
  26.     {% include('navbarlogin.html.twig') %}
  27.     <div class="container-fluid top-buffer70">
  28.         <div class="container content justify">
  29.             {% if data.idDoc is defined and data.idDoc is not null %}
  30.                 <div class="box-header">
  31.                     <div class="row">
  32.                         <div class="col-sm-8">
  33.                             <h4>{{ data.docCode }}</h4>
  34.                             <h3>{{ data.title }}</h3>
  35.                         </div>
  36.                         {% if is_granted('ROLE_GLOBAL_EDITOR') %}
  37.                             <div class="col-sm-4 pull-right">
  38.                                 <a
  39.                                         href="{{ path('edit_document',{idDoc:data.idDoc}) }}">
  40.                                     [Edit this Document]
  41.                                 </a>
  42.                                 {% if data.docGroupList | length > 0 %}
  43.                                     <br/>
  44.                                     unable to delete, used in a doclist
  45.                                 {% endif %}
  46.                                 {% if data.docEventList | length > 0 %}
  47.                                     <br/>
  48.                                     unable to delete, used in an event
  49.                                 {% endif %}
  50.                                 {% if data.docGroupList | length == 0
  51.                                     and data.docEventList | length == 0 %}
  52.                                     <br/>
  53.                                 <a
  54.                                         href="javascript:void(0);"
  55.                                         id="deleteDocument"
  56.                                         data-idDoc="{{ data.idDoc }}">
  57.                                     [Delete this Document]
  58.                                 </a>
  59.                                 {% endif %}
  60.                             </div>
  61.                         {% endif %}
  62.                     </div>
  63.                     <div class="table-responsive col-md-10">
  64.                         <table class="table documentDetails">
  65.                             <tbody>
  66.                             {% if data.authorText is defined and data.authorText != "" %}
  67.                                 <tr>
  68.                                     <th>Author(s)</th>
  69.                                     <td>{{ data.authorText }}</td>
  70.                                 </tr>
  71.                             {% endif %}
  72.                             {% if data.summary is defined and data.summary != "" %}
  73.                                 <tr>
  74.                                     <th>Summary</th>
  75.                                     <td>{{ data.summary | raw }}</td>
  76.                                 </tr>
  77.                             {% endif %}
  78.                             {% if data.doctypename is defined and data.doctypename != "" %}
  79.                                 <tr>
  80.                                     <th>Doc Type</th>
  81.                                     <td>{{ data.doctypename }}</td>
  82.                                 </tr>
  83.                             {% endif %}
  84.                             {% if data.idDoctype is defined and data.idDoctype == 9 %}
  85.                                 <tr>
  86.                                     <th>URL</th>
  87.                                     <td>
  88.                                         <a
  89.                                                 href="{{ data.url }}"
  90.                                                 target="_blank">
  91.                                             {{ data.url }}
  92.                                         </a>
  93.                                     </td>
  94.                                 </tr>
  95.                             {% endif %}
  96.                             {% if data.idDocstatus == 1  %}
  97.                                 {% set status = "Draft" %}
  98.                             {% elseif data.idDocstatus == 2 %}
  99.                                 {% set status = "Published" %}
  100.                             {% elseif data.idDocstatus == 3 %}
  101.                                 {% set status = "Pending" %}
  102.                             {% endif %}
  103.                             <tr>
  104.                                 <th>Status</th>
  105.                                 <td>
  106.                                     {{ status }}
  107.                                     {% if data.publishedOn is defined and data.publishedOn != "" %}
  108.                                         on {{ data.publishedOn|date('d M Y') }}
  109.                                     {% endif %}
  110.                                 </td>
  111.                             </tr>
  112.                             {% if data.notes is defined and data.notes != "" %}
  113.                                 <tr>
  114.                                     <th>Notes</th>
  115.                                     <td>{{ data.notes | raw }}</td>
  116.                                 </tr>
  117.                             {% endif %}
  118.                             {% if data.keywords is defined and data.keywords != "" %}
  119.                                 <tr>
  120.                                     <th>Keywords</th>
  121.                                     <td>{{ data.keywords }}</td>
  122.                                 </tr>
  123.                             {% endif %}
  124.                             {% if data.docGroupList | length > 0 %}
  125.                                 <tr>
  126.                                     <th>This document is in the list(s):</th>
  127.                                     <td>
  128.                                         {% for docGroupList in  data.docGroupList %}
  129.                                             <a
  130.                                                     href="{{ path('view_doclist',{idDoclist:docGroupList.idDoclist}) }}">
  131.                                                 {{ docGroupList.title }}
  132.                                             </a>
  133.                                             <br/>
  134.                                         {% endfor %}
  135.                                     </td>
  136.                                 </tr>
  137.                             {% endif %}
  138.                             {% if data.docEventList | length > 0 %}
  139.                                 <tr>
  140.                                     <th>This document is used in the event(s):</th>
  141.                                     <td>
  142.                                         {% for docEventList in data.docEventList %}
  143.                                             <a
  144.                                                     href="{{ path('view_event',{event:docEventList.idEvent}) }}"
  145.                                                     target="_blank">
  146.                                                 {{ docEventList.title }}
  147.                                             </a>
  148.                                             <br/>
  149.                                         {% endfor %}
  150.                                     </td>
  151.                                 </tr>
  152.                             {% endif %}
  153.                             </tbody>
  154.                         </table>
  155.                     </div>
  156.                 </div>
  157.                 {% if data.docFiles | length > 0 %}
  158.                     <div class="row">
  159.                     <div class="col-xs-10">
  160.                         <div class="panel panel-success">
  161.                             <div class="panel-heading">
  162.                                 <i class="fa fa-download fa-fw fa-2x" aria-hidden="true"></i>
  163.                                 Download
  164.                             </div>
  165.                             <div class="panel-body">
  166.                                 {% for file in data.docFiles %}
  167.                                     <div class="files col-md-4">
  168.                                         <a
  169.                                             href="{{ path('download_document',{idFile:file.idFile}) }}"
  170.                                             target="_blank"
  171.                                             onclick="ga('send', 'event', 'documents', 'download', '{{ data.idDoc }}-{{ file.languagename }}-{{ data.title }}');"
  172.                                             download="">
  173.                                             {% if file.idFileformat == 1 %}
  174.                                                 <img src="{{ asset('images/fileicons/pdf.png') }}" alt="PDF" class="fileicon">
  175.                                             {% elseif file.idFileformat == 2 %}
  176.                                                 <img src="{{ asset('images/fileicons/doc.png') }}" alt="DOC" class="fileicon">
  177.                                             {% elseif file.idFileformat == 3 %}
  178.                                                 <img src="{{ asset('images/fileicons/txt.png') }}" alt="TXT" class="fileicon">
  179.                                             {% elseif file.idFileformat == 4 %}
  180.                                                 <img src="{{ asset('images/fileicons/rtf.png') }}" alt="RTF" class="fileicon">
  181.                                             {% elseif file.idFileformat == 5 %}
  182.                                                 <img src="{{ asset('images/fileicons/xls.png') }}" alt="XLS" class="fileicon">
  183.                                             {% elseif file.idFileformat == 6 %}
  184.                                                 <img src="{{ asset('images/fileicons/ppt.png') }}" alt="PPT" class="fileicon">
  185.                                             {% elseif file.idFileformat == 7 %}
  186.                                                 <img src="{{ asset('images/fileicons/ppt.png') }}" alt="PPT" class="fileicon">
  187.                                             {% elseif file.idFileformat == 8 %}
  188.                                                 <img src="{{ asset('images/fileicons/gif.png') }}" alt="GIF" class="fileicon">
  189.                                             {% elseif file.idFileformat == 9 %}
  190.                                                 <img src="{{ asset('images/fileicons/jpg.png') }}" alt="JPG" class="fileicon">
  191.                                             {% elseif file.idFileformat == 10 %}
  192.                                                 <img src="{{ asset('images/fileicons/jpg.png') }}" alt="JPG" class="fileicon">
  193.                                             {% elseif file.idFileformat == 11 %}
  194.                                                 <img src="{{ asset('images/fileicons/png.png') }}" alt="PNG" class="fileicon">
  195.                                             {% elseif file.idFileformat == 12 %}
  196.                                                 <img src="{{ asset('images/fileicons/bmp.png') }}" alt="BMP" class="fileicon">
  197.                                             {% elseif file.idFileformat == 13 %}
  198.                                                 <img src="{{ asset('images/fileicons/zip.png') }}" alt="ZIP" class="fileicon">
  199.                                             {% elseif file.idFileformat == 14 %}
  200.                                                 <img src="{{ asset('images/fileicons/xlsx.png') }}" alt="XLSX" class="fileicon">
  201.                                             {% elseif file.idFileformat == 15 %}
  202.                                                 <img src="{{ asset('images/fileicons/ppt.png') }}" alt="PPT" class="fileicon">
  203.                                             {% elseif file.idFileformat == 16 %}
  204.                                                 <img src="{{ asset('images/fileicons/ppt.png') }}" alt="PPT" class="fileicon">
  205.                                             {% elseif file.idFileformat == 17 %}
  206.                                                 <img src="{{ asset('images/fileicons/doc.png') }}" alt="DOC" class="fileicon">
  207.                                             {% endif %}
  208.                                             {{ file.languagename }}
  209.                                         <span class="small">
  210.                                             (v{{ file.version }}, {{ file.size|format_bytes }})
  211.                                         </span>
  212.                                         </a>
  213.                                     </div>
  214.                                 {% endfor %}
  215.                             </div>
  216.                         </div>
  217.                     </div>
  218.                 {% endif %}
  219.                 </div>
  220.                     <div class="row">
  221.                     <hr/>
  222.                     <div class="col-xs-12">
  223.                         <div class="pull-right text-right stats">
  224.                             {% if data.documentGroup is defined and data.documentGroup | length >0 %}
  225.                                 <div>Group(s):
  226.                                     {% for documentGroup in  data.documentGroup %}
  227.                                         {{ documentGroup.groupname }}
  228.                                     {% endfor %}
  229.                                 </div>
  230.                             {% endif %}
  231.                             <div>
  232.                                 {% if data.createdAt is defined and data.createdAt != "" %}
  233.                                     {{ "Created at " ~ data.createdAt | date("H:i") ~ ' on ' ~ data.createdAt | date("d M Y") }}
  234.                                 {% endif %}
  235.                                 {% if data.createdBy is defined and data.createdBy != "" %}
  236.                                     {{ ' by ' ~ data.createdBy }}
  237.                                 {% endif %}
  238.                             </div>
  239.                             <div>
  240.                                 {% if data.updatedAt is defined and data.updatedAt != "" %}
  241.                                     {{ "Updated at " ~ data.updatedAt | date("H:i") ~ ' on ' ~ data.updatedAt | date("d M Y") }}
  242.                                 {% endif %}
  243.                                 {% if data.updatedBy is defined and data.updatedBy != "" %}
  244.                                     {{ ' by ' ~ data.updatedBy }}
  245.                                 {% endif %}
  246.                             </div>
  247.                         </div>
  248.                     </div>
  249.                 </div>
  250.                     {% if is_granted('ROLE_GLOBAL_EDITOR') %}
  251.                     <div class="row">
  252.                         <hr/>
  253.                         <div class="col-xs-12 bg-info">
  254.                             <div class="form-group">
  255.                                 <label for="" class="col-sm-3 control-label">Add this document to a list</label>
  256.                                 <div class="col-sm-9">
  257.                                     <select name="addDocGroup" id="addDocGroup" class="addDoclist">
  258.                                         <option value="">Select Group</option>
  259.                                         {% for groups in data.docGroupListAll %}
  260.                                             {% if groups.idDoclist not in data.docGroupListArr %}
  261.                                                 <option value="{{ groups.idDoclist }}">{{ groups.title }}</option>
  262.                                             {% endif %}
  263.                                         {% endfor %}
  264.                                     </select>
  265.                                     <button
  266.                                             class="btn btn-md btn-success"
  267.                                             id="addGroupList"
  268.                                             type="button">
  269.                                         Add
  270.                                     </button>
  271.                                 </div>
  272.                             </div>
  273.                         </div>
  274.                     </div>
  275.                 {% endif %}
  276.             {% else %}
  277.                 <div class="alert alert-danger" role="alert">
  278.                     <i class="fa fa-exclamation-triangle fa-fw fa-2x"></i>
  279.                     The requested document could not be found. (maybe it has not been approved yet)
  280.                 </div>
  281.                 <a
  282.                         class="btn btn-success"
  283.                         href="{{ path('frontend_homepage') }}">
  284.                     Click here to go to Home
  285.                 </a>
  286.             {% endif %}
  287.         </div>
  288.     </div>
  289.     {% include "footer.html.twig" %}
  290.     <script src="{{ asset('js/jquery-confirm.min.js') }}"></script>
  291.     <script type="text/javascript" class="init">
  292.         $(document).ready(function() {
  293.             //set the top nav menu style
  294.             $(".documents").addClass('navactive');
  295.         });
  296.     </script>
  297.     {% if data.idDoc is defined and data.idDoc is not null %}
  298.         <script type="text/javascript">
  299.             var deleteDocument = "{{ path('delete_document') }}"
  300.             var documentsPage = "{{ path('view_documents') }}";
  301.         $("#addGroupList").click(function () {
  302.             $(".error").remove();
  303.             var $this=$(this);
  304.             $this.parents(".form-group").removeClass("has-error");
  305.             $("#addDocGroup").css("border-color","none");
  306.             var idDoclist = $("#addDocGroup option:selected").val();
  307.             var idDoc = {{ data.idDoc }};
  308.             if (idDoclist != "") {
  309.                 $.ajax({
  310.                     url: "{{ path('add_document_to_doc_list') }}",
  311.                     data: {idDoclist: idDoclist, idDoc: idDoc},
  312.                     method: "POST",
  313.                 }).done(function (response) {
  314.                     if(response.status == 1){
  315.                         window.location.reload();
  316.                     }
  317.                 });
  318.             } else {
  319.                 $("#addDocGroup").css("border-color","red");
  320.                 $this.parents(".form-group").addClass('has-error');
  321.                 $this.after("<div class='text-danger error'>Please select documentlist</div>");
  322.             }
  323.         });
  324.         $("#deleteDocument").click(function () {
  325.             var $this = $(this);
  326.             var idDoc = $this.data("iddoc");
  327.             let warningText = 'The removal of this document is an irreversible process. ' +
  328.                 'It will no longer be visible to other users. ' +
  329.                 'Are you sure you want to delete it forever?';
  330.             $.confirm({
  331.                 escapeKey: "cancel",
  332.                 title: 'Confirm!',
  333.                 content: warningText,
  334.                 buttons: {
  335.                     confirm:{
  336.                         keys: ['enter'],
  337.                         btnClass: 'btn-primary',
  338.                         text: "OK",
  339.                         action: function(){
  340.                             $.ajax({
  341.                                 url: deleteDocument,
  342.                                 data:{idDoc: idDoc},
  343.                                 method: "POST"
  344.                             }).done(function (response) {
  345.                                 if(response.status==1 ){
  346.                                     window.location.href = documentsPage;
  347.                                 } else {
  348.                                     alert(response.message);
  349.                                 }
  350.                             });
  351.                         }
  352.                     },
  353.                     cancel: function () {
  354.                         btnClass: 'btn-danger'
  355.                     }
  356.                 }
  357.             });
  358.         });
  359.     </script>
  360.     {% endif %}
  361. {% endblock %}