<commit_before>{% extends "reports/show.html" %}
{% load i18n %}
{% load tags %}

{% block script %}
{{ block.super }}

{% block specific_scripts %}
<script src="{{ STATIC_URL }}js/bootstrap-datepicker.js"></script>
<script src="{{ STATIC_URL }}js/locales/bootstrap-datepicker.fr.js"></script>
<script src="{{ STATIC_URL }}js/locales/bootstrap-datepicker.nl.js"></script>
<script src="{{ STATIC_URL }}js/jquery.exif.js"></script>
<link   href="{{ STATIC_URL }}css/datepicker.css" rel="stylesheet" type="text/css"/>

<script type="text/javascript">

var URL_REPORT_REFUSE = "{% url 'report_refuse_pro' report.id %}";

$(function(){
    /**********************************************/
    /* Prepare iphone toogle button look and feel */
    /**********************************************/
    $("input[type=radio]").bind("click",function(){
        var id = $(this).data('attachmentId');
        var level = $(this).val();
        window.location = '{% url "report_update_attachment" report.id %}?attachmentId='+id+'&updateType='+level;
    });

    /***************************/
    /* Set the current manager */
    /***************************/
    $("#report_responsible_manager_select").val("department_{{report.responsible_department.id}}");

    /*************************************************************/
    /* Implement method when changing manager using the dropdown */
    /*************************************************************/
    $("#report_responsible_manager_select").bind("change",function(event){
        var r=confirm("{% trans 'Are you sure you want to change the responsable manager? This action cannot be undone.' %}");
        if (r==true){
            window.location = '{% url "report_change_manager_pro" report.id %}?manId='+$("#report_responsible_manager_select").val();
        }
        else{
            $("#report_responsible_manager_select").val("department_{{report.responsible_department.id}}");
        }
    });
    /******************************/
    /* Set the current contractor */
    /******************************/
    $("#report_responsible_impetrant_contractor_select").val("contractor_{{report.subcontractor.id}}");

    /****************************************************************/
    /* Implement method when changing contractor using the dropdown */
    /****************************************************************/
    $("#report_responsible_impetrant_contractor_select").bind("change",function(event){

        var r=confirm("Are you sure you want to change the contractor/applicant?");
        if (r==true){
            window.location = '{% url "report_change_contractor_pro" report.id %}?contractorId='+$("#report_responsible_impetrant_contractor_select").val();
        }
        else{
            $("#report_responsible_impetrant_contractor_select").val("contractor_{{report.subcontractor.id}}");
        }
    });
    /****************************************************************/
    /* Implement method when clicking private/public checkbox       */
    /****************************************************************/
    $("#id_private").bind("click",function(event){
        var r2=confirm("{% trans 'Are you sure you want to make the incident private? This will notify all public subscribers.' %}");
        if (r2==true){
            window.location = '{% url "report_change_switch_privacy" report.id %}?privacy='+$("#id_private").is(":checked");
        }
        else {
            $('#id_public').attr("checked", "checked");
            window.location = '{{report.get_absolute_url_pro}}';
        }
    });
    $("#id_public").bind("click",function(event){
            window.location = '{% url "report_change_switch_privacy" report.id %}?privacy='+$("#id_private").is(":checked");
    });
    {% if subscribed %}
    $("#id_pro-subscription").attr("value","on").prop('checked', true);
    {% else %}
    $("#id_pro-subscription").attr("value","off");
    {% endif %}

    $("#id_pro-subscription").change(function(){
        if($(this).attr("value")== "on"){
            $(this).attr("value","off");
            $.ajax("{% url 'unsubscribe_pro' report.id %}")
        }
        else{
            $(this).attr("value","on");
            $.ajax("{% url 'subscribe_pro' report.id %}");
        }
    });

    $("#grav").val("{{report.gravity}}");
    $("#prob").val("{{report.probability}}");




});
/* When JQUERY is ready*/
$(document).ready(function() {
    /*Set the contractor dropdown*/
    $('#report_responsible_impetrant_contractor_select').val('{{report.contractor.id}}');
    /*Set the checked value*/
    {% if report.private %}
        $('#id_private').attr("checked", "checked");
    {% else %}
        $('#id_public').attr("checked", "checked");
    {% endif %}
    var markers = [];
    {% for report in reports %}
        var reportJSON = $.extend({}, {{ report.to_JSON|dict_to_json|safe }}, {{ report.marker_detail_JSON|dict_to_json|safe }});

        {% if BACKOFFICE %}
            reportJSON = $.extend(reportJSON, {{ report.marker_detail_pro_JSON|dict_to_json|safe }});
        {%endif%}
        markers.push(fms.currentMap.addReport(reportJSON, {{forloop.counter}}, {% if BACKOFFICE %}true{%else%}false{%endif%}, true));
        fms.currentMap.markersLayer.addFeatures(markers);
    {% endfor %}
    //Clear the comment textarea after each POST
    $("#id_comment-text").val('');

    // False address
    var report_false_adress = "{{ report.false_address }}";

    document.getElementById('mailPDFProButton').addEventListener('click', function() {
        mailbox = document.getElementById('mail_pdf');
        if (mailbox.classList.contains('hidden'))
            mailbox.classList.remove('hidden');
        else
            mailbox.classList.add('hidden');
            document.getElementById('mail_pdf_emailaddresses').value = '';
            document.getElementById('mail_pdf_emailcomments').value ='';
    });

    document.getElementById('mailPDFCitizenButton').addEventListener('click', function() {
        mailbox = document.getElementById('mail_pdf_citizen');
        if (mailbox.classList.contains('hidden'))
            mailbox.classList.remove('hidden');
        else
            mailbox.classList.add('hidden');
            document.getElementById('mail_pdf_emailaddresses_citizen').value = '';
            document.getElementById('mail_pdf_emailcomments_citizen').value ='';
    });



    var isFalseAddressCheckBox = document.getElementById('is_false_address');
    isFalseAddressCheckBox.addEventListener('change', function() {
        var falseAddress_Reason = document.getElementById('false_address');
        if (this.checked) {
            falseAddress_Reason.classList.remove('hidden');
        } else {
            falseAddress_Reason.classList.add('hidden');
        }
    });

    document.getElementById('false_address').addEventListener('keyup', function() {
        if (this.value != report_false_adress) {
            document.getElementById('submit_false_address').classList.remove('hidden');
        } else {
            document.getElementById('submit_false_address').classList.add('hidden');
        }
    });

    document.getElementById('submit_false_address').addEventListener('click', function() {
        // Ajax request to set false_address
        var false_address = document.getElementById('false_address').value;
        var url = '{% url "report_false_address" report.id %}';
        var data = { 'false_address': false_address };

        var self = this;
        $.post( url, data, function( result ) {
            // Do nothing
            self.classList.add('hidden');
            report_false_adress = result;
        });
    });

    document.getElementById("send_pdf_citizen_button").addEventListener('click', function(event){
        $.ajax({
            url:"{% url 'send_pdf' report.id %}",
            data:{"to":$('#mail_pdf_emailaddresses_citizen').val(), "comments":$('#mail_pdf_emailcomments_citizen').val(), "privacy":"public"},
            type:"POST",
            success:function(data){
                alert(data);
                document.getElementById('mailPDFCitizenButton').click();
            }
        });


    });

    document.getElementById("send_pdf_pro_button").addEventListener('click', function(event){
        $.ajax({
            url:"{% url 'send_pdf' report.id %}",
            data:{"to":$('#mail_pdf_emailaddresses').val(), "comments":$('#mail_pdf_emailcomments').val(), "privacy":"private"},
            type:"POST",
            success:function(data){
                alert(data);
                document.getElementById('mailPDFProButton').click();
            }
        });


    });

    $("#main_cat_select").val("{{report.category.id}}");
    $.ajax({
        url:"{% url 'secondary_category_for_main_category' %}?main_category="+"{{report.category.id}}",
        type:"GET",
        success:function(data){
            for(var i = 0; i<data.length;++i){
                {% if report.private %}
                    var option = "<option value='"+data[i].id+"'>"+data[i]["n_"+LANGUAGE_CODE]+"/"+data[i]["s_c_n_"+LANGUAGE_CODE]+"</option>";
                    $("#sec_cat_select").append(option);
                {% else %}
                if(data[i].p === 1){
                    var option = "<option value='"+data[i].id+"'>"+data[i]["n_"+LANGUAGE_CODE]+"/"+data[i]["s_c_n_"+LANGUAGE_CODE]+"</option>";
                    $("#sec_cat_select").append(option);
                }
                {% endif %}
            }
            $("#sec_cat_select").val("{{report.secondary_category.id}}");
        }

    });
    $('#main_cat_select').change(function(){
        if(this.value !== "0"){
            $("#sec_cat_select").removeAttr("disabled");
            $("#sec_cat_select").empty();
            $("#sec_cat_select").append('<option value="0">{% trans "Select a Category" %}</option>');
            $.ajax({
                url:"{% url 'secondary_category_for_main_category' %}?main_category="+this.value,
                type:"GET",
                success:function(data){
                    for(var i = 0; i<data.length;++i){
                        {% if report.private %}
                            var option = "<option value='"+data[i].id+"'>"+data[i]["n_"+LANGUAGE_CODE]+"/"+data[i]["s_c_n_"+LANGUAGE_CODE]+"</option>";
                            $("#sec_cat_select").append(option);
                        {% else %}
                        if(data[i].p === 1){
                            var option = "<option value='"+data[i].id+"'>"+data[i]["n_"+LANGUAGE_CODE]+"/"+data[i]["s_c_n_"+LANGUAGE_CODE]+"</option>";
                            $("#sec_cat_select").append(option);
                        }
                        {% endif %}
                    }

                }
            });
        }
        else {
            $("#sec_cat_select").attr("disabled","disabled");
        }
    });

    $("#sec_cat_select").change(function(){
        $.ajax({
            url:"{% url 'update_category_for_report' report.id %}",
            data:{"main_category":$('#main_cat_select').val(),"secondary_category":this.value},
            type:"POST",
            success:function(data){
                //do nothing
            }
        });
    })

    $($(".update_text").find('#imgtoshow')).exifLoad(someCallback);
});

window.onload = function() {
    // Handle 'I want to create a new report' checkbox
    var createNewReport = document.getElementById('createNewReport');

    if (createNewReport) {
        messageButton.addEventListener('click', function() {
            if (createNewReport.checked) {
                window.location.href = "/";
            }
        });
    }
}

function close(){
    var r=confirm("Are you sure you want to close this report?");
    if (r==true){
        window.location = "{% url 'report_close_pro' report.id %}";
    }
}

function updatePriority(){
    var a = parseInt($("#grav").val());
    var b = parseInt($("#prob").val());
    $.ajax({url:"{% url 'report_update_priority' report.id %}",
        data:{"gravity":a,"probability":b},
        type:'GET',
        datatype:"json",
        success: function(data){
            $("#prio_result").html(data.priority);
        }
    });


}

function showNearbyReports(){
    $("#merge_nearby_reports_popup").modal();
}

function mergeReport(){
    $("#merge_confirm_popup").modal("hide");

    window.location = "{% url 'report_merge_pro' report.id %}?mergeId="+selected;
}
function planned(){
    var date_planned = document.getElementById('date_planned').value;

    if (date_planned) {
        var url = "{% url 'report_planned_pro' report.id %}?date_planned=" + date_planned;
        window.location = url;
    }
}

function showMergeConfirmation(){
    $("#merge_nearby_reports_popup").modal("hide");
    $("#merge_confirm_popup").modal();
}

var someCallback = function(exifObject, index) {
        if (exifObject && exifObject.DateTimeOriginal){
            textAreas = $($(".update_text").find('#imagedate'));
            var datetosplit = exifObject.DateTimeOriginal;
            var splitted = datetosplit.split(/[:,\/ ]/)
            var pictureDate = new Date(splitted[0], splitted[1] -1, splitted[2], splitted[3], splitted[4], splitted[5], 0);
            textAreas[index].innerHTML = splitted[2] + '-' + splitted[1] + '-' + splitted[0] + " " +splitted[3] + ":" +splitted[4];
            }
        }



</script>
<script src="{{ STATIC_URL}}js/reports_show_pro.js"></script>
{% endblock %}
{% endblock %}

{% block css %}
{{ block.super }}
{% endblock %}

{% block map %}
<div class="container">
    <div class="row">
        <div class="span12">
            <article id="map" class="view_incident">
                <div id="incident-head">
                    <div class="row">
                        <div class="span3">
                            <div class="ticket_infos">
                                <span class="ticket_number">
                                    <img src="{{STATIC_URL}}{{ report.get_marker}}" /> {% trans 'Incident n°' %} {{ report.get_ticket_number }}
                                </span><br />
                                <span class="ticket_address">
                                    {{ report.address }}, {{ report.address_number }}<br />
                                    {{ report.postalcode }} {{ report.get_address_commune_name }}
                                </span><br />
                                <span class="ticket_desc">
                                    {{ report.display_category }}
                                </span>
                            </div>
                        </div>
                        <div class="span6">
                            timeline
                        </div>
                        <div class="span3">
                            {% if report.is_in_progress %}
                                {% if report.status != report.SOLVED %}
                                    <a href="#divMarkAsDone" role="button" class="btn lk-isresolved" data-toggle="modal">
                                        <i class="isresolved"> </i>{% trans "Signaler résolu" %}
                                    </a>
                                {% endif %}

                                {% if not report.is_closed and not subscribed %}
                                    <a href="#modalSubscription" role="button" class="btn lk-subscribe" data-toggle="modal">
                                        {% if report.subscriptions.all.count %}
                                            <span class="badge badge-inverse">{{ report.subscriptions.all.count }}</span>
                                        {% endif %}
                                        <i class="subscribe"> </i>

                                        {% trans "S'abonner" %}
                                    </a>
                                {% endif %}
                            {% endif %}

                            <a class="lk-download-pdf btn" href="{% url 'report_pdf' report.id %}" title="{% trans 'Download a pdf report of this incident' %}">
                                <!--i class="icon-download" /--><i class="download-pdf"> </i>{% trans 'Télécharger' %}
                            </a>
                        </div>
                    </div>
                </div>
                <div id="copyright-urbis">Realized by means of Brussels UrbIS®©</div>
                <div id="btn-pulldownmap"><a href="#"><i class="icon-pulldownmap"></i>{% trans "Agrandir la carte" %}</a></div>
                <div id="btn-streetview"><a href="#"><i class="icon-streetview"></i>{% trans "Street View" %}</a></div>
            </article>
        </div>
    </div>
</div>
{% endblock %}

{% block content %}
<div id="divMarkAsDone" class="modal hide fade" role="dialog">
    <div class="modal-body">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <form id="dialogMarkAsDone" title="Please enter more information about marking the report as done" action="{% url 'report_fix_pro' report.id %}?is_fixed=True" method="post" >
            {% include "_form_horizontal.html" with form=mark_as_done_form %}
            <input type="button" class="btn"  value="{% trans 'Cancel'%}" data-dismiss="modal" aria-hidden="true"/>
            <input type="submit" class="btn"  value="{% trans 'Confirm'%}"/>
        </form>
    </div>
</div>

<div id="divRefuse" class="modal hide fade" role="dialog">
    <div class="modal-body">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <form id="dialog" title="Please enter more information about rejecting the report" action="{% url 'report_refuse_pro' report.id %}" method="post">
            {% include "_form_horizontal.html" with form=refuse_form %}
            <input type="button" class="btn"  value="{% trans 'Cancel'%}" data-dismiss="modal" aria-hidden="true"/>
            <input type="submit" class="btn"  value="{% trans 'Confirm'%}"/>
        </form>
    </div>
</div>

<div id="history_popup" class="modal hide fade" role="dialog">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h2>{% trans 'History' %} {% trans 'incident '%} {{report.get_ticket_number}}</h2>
    </div>
    <div class="modal-body">
        {% include "reports/_activity_list.html" with  privacy='private' %}
    </div>
    <div class="modal-footer">
        <input type="button" class="btn"  value="{% trans 'OK'%}" data-dismiss="modal" aria-hidden="true"/>
    </div>
</div>

<h1 class="span12">
    {% if report.is_in_progress %}
        <img src="{{STATIC_URL}}{{report.get_marker}}" style="max-width:30px;" />
    {% else %}
        <img src="{{STATIC_URL}}{{report.get_marker}}" style="max-width:30px;" />
    {% endif %}
    {% trans "Report Ticket" %} {{ report.get_ticket_number }}
</h1>

<div class="span6">
    <div class="bordered-box">
        {% if not report.is_merged %}
            {% if report.is_created %}
                <div class='is_created'>{% trans "This incident is not validated." %}</div>
            {% endif %}

            {% if report.is_refused %}
                <div class='is_created'>
                    <p>{% trans "This problem has been refused." %}</p>
                    <p>{{ report.refusal_motivation }}</p>
                </div>
            {% endif %}

            {% if report.is_in_progress %}
                <div class="is_in_progress">{% trans "This incident is in progress." %}</div>
            {% endif %}

            {% if report.is_closed %}
                <div class='is_fixed'>{% trans "This incident has been closed." %}</div>
            {% endif %}
        {% else %}
            <div class='is_fixed'>{% trans "This report has been merged with report: " %}<a href="{{report.merged_with.get_absolute_url_pro}}" >{{report.merged_with.get_ticket_number}}</a></div>
        {% endif %}
        <div id='report-body'>
            <p>
                {% if report.description %}
                    {{report.description|linebreaks}}
                {% endif %}
            </p>
            <p class="author-sign">
                {% if report.citizen %}
                    <!-- Protect privacy from applicant and contractor when creator is a citizen -->
                    {% if fms_user.can_see_confidential %}
                        {% if report.citizen.last_name = ''%}
                            {% blocktrans with by=report.citizen.last_name on=report.created|date mail=report.citizen.email %}
                                Posted by <strong><a href='mailto:{{mail}}'>ANONYMOUS</a></strong> on <strong>{{on}}</strong>
                            {% endblocktrans %}
                        {% else %}
                            {% blocktrans with by=report.citizen.last_name on=report.created|date mail=report.citizen.email %}
                                Posted on <strong>{{on}}</strong> by <strong><a href='mailto:{{mail}}'>{{by}}</a></strong>
                            {% endblocktrans %}
                            (tel:{{report.citizen.fmsuser.telephone}})
                        {% endif %}
                    {% else %}
                        {% blocktrans with on=report.created %}
                            Posted on <strong>{{on}}</strong>
                        {% endblocktrans %}
                   {% endif %}
               {% else %}
                   {% blocktrans with by=report.created_by.get_full_name on=report.created mail=report.created_by.email %}
                        Posted by <strong><a href='mailto:{{mail}}'>{{by}}</a></strong> on <strong>{{on}}</strong>
                   {% endblocktrans %}
                   (tel:{{report.created_by.fmsuser.telephone}})
               {% endif %}
            </p>

            <!-- ################## -->
            <!-- # REPORT DETAILS # -->
            <!-- ################## -->
            <table id='report-status'>
                <tr>
                    <th><strong>{% trans "Location:" %}</strong></th>
                    <td colspan="3">{{report.address}}, {{report.address_number}} ({{report.postalcode}} {{report.get_address_commune_name}})</td>
                </tr>

                {% if report.responsible_department in request.fmsuser.organisations_list and not report.is_merged %}
                <tr>
                    <th><strong>{% trans "Wrong address:" %}</strong></th>
                    <td colspan="2"><textarea id="false_address" name="false_address" {% if not report.false_address %}class="hidden"{% endif %}>{% if report.false_address %}{{ report.false_address }}{% endif %}</textarea></td>
                    <td colspan="1"><input type="checkbox" id="is_false_address" {% if report.false_address %}checked{% endif %}></td>
                    <td colspan="1"><span id="submit_false_address" class="btn hidden" style="float:right;">Valider</span></td>
                </tr>
                {% else %}
                    {% if report.false_address %}
                        <tr>
                            <th><strong>{% trans "Wrong address:" %}</strong></th>
                            <td colspan="2">{{report.false_address}}</td>
                        </tr>
                    {% endif %}
                {% endif %}
                {% if report.responsible_department in request.fmsuser.organisations_list and report.is_in_progress and not report.is_merged %}
                <tr>
                    <th><strong>{% trans "Category:" %}</strong></th>
                    <td colspan="4">
                            <select id="main_cat_select">
                                <option value="0">{% trans "Select a Category" %}</option>
                                {% for cat in category_list%}
                                    <option value="{{cat.id}}">{{cat.name}}</option>
                                {% endfor %}
                            </select>
                    </td>
                </tr>
                <tr>
                    <th><strong>{% trans "Secondary category:" %}</strong></th>
                    <td colspan="4">
                        <select id="sec_cat_select"><option value="0">{% trans "Select a Category" %}</option></select>
                    </td>
                </tr>
                {% else %}
                <tr>
                    <th><strong>{% trans "Category:" %}</strong></th>
                    <td colspan="4">
                    {{report.display_category}}
                    </td>
                </tr>
                {% endif %}
                <tr>
                    <th><strong>{% trans "Status:" %}</strong></th>
                    <td>{{ report.get_status_display }}</td>
                </tr>

                {% if not report.is_in_progress %}
                <tr>
                    <th><strong>{% trans "Responsible:" %}</strong></th>
                    <td>{{ report.responsible_department.name }} ({{report.responsible_department.dependency.name}})</td>
                </tr>
                {% endif %}

                {% if report.is_in_progress %}
                    {% if report.responsible_department in request.fmsuser.organisations_list and not report.is_merged %}
                        <!-- ############################### -->
                        <!-- # RESPONSIBLE/ENTITY DROPDOWN # -->
                        <!-- ############################### -->
                        <tr>
                            <th><strong>{% trans "Responsible manager:" %}</strong></th>
                            <td colspan="4">
                                <select id="report_responsible_manager_select">
                                   <optgroup label="{% trans 'Gestionnaires' %}">
                                    {% for department in departments %}
                                        <option value="department_{{department.id}}">{{department.name}} ({{ department.dependency.name}})</option>
                                    {% endfor %}
                                    </optgroup>
                                    <optgroup label="{% trans 'Entites' %}">
                                    {% for entity in entities %}
                                        <option value="entity_{{entity.id}}">{{entity.name}}</option>
                                    {% endfor %}
                                    </optgroup>
                                    <optgroup label="{% trans 'Organisms' %}">
                                    {% for institution in region_institution %}
                                        <option value="entity_{{institution.id}}">{{institution.name}}</option>
                                    {% endfor %}
                                    </optgroup>
                                </select>
                            </td>
                        </tr>
                        <!-- ################################# -->
                        <!-- # CONTRACTOR/IMPETRANT DROPDOWN # -->
                        <!-- ################################# -->
                        <tr>
                            <th><strong>{% trans "Contractor/Applicant:" %}</strong></th>
                            <td colspan="4">
                                <select id="report_responsible_impetrant_contractor_select">
                                    <option value="None">{% trans 'No selected contractor/applicant' %}</option>
                                        <optgroup label="Executeur de travaux">
                                        {% for organisation in contractors %}
                                        <option value="{{organisation.id}}">{{ organisation.name }}</option>
                                        {% endfor %}
                                    </optgroup>
                                    <optgroup label="Impetrants">
                                    {% for applicant in applicants %}
                                        <option value="{{applicant.id}}">{{ applicant.name }}</option>
                                    {% endfor %}
                                    </optgroup>
                                </select>
                                {% if report.contractor %}
                                <ul>
                                    {% for contact_person in report.contractor.workers.all %}
                                        <li>
                                            {{ contact_person.get_full_name }}
                                            {% if contact_person.telephone %}(tel:{{contact_person.telephone}}) {% endif %}
                                         </li>
                                    {% endfor %}
                                </ul>
                                {% endif %}
                            </td>
                        </tr>
                        <!-- ################################# -->
                        <!-- # PUBLIC OR PRIVATE CHECKBOX    # -->
                        <!-- ################################# -->
                        <tr>
                            <th>
                                <strong>{% trans "Visibility:" %}</strong>
                            </th>
                            <td colspan="2">
                                <input type="radio" id="id_private" name="public_private">
                                {% trans "Private" %}
                            </td>
                            <td colspan="2">
                                <input type="radio" id="id_public" name="public_private">
                                {% trans "Public" %}
                            </td>
                        </tr>
                        <!-- ############ -->
                        <!-- # PRIORITY # -->
                        <!-- ############ -->
                        <tr>
                            <th>
                                <strong>{% trans "Priority:" %} </strong>
                            </th>
                            <td colspan="2">
                                <span>{% trans "Probability:" %}</span>
                                <select style="width:50px;" id="prob" onchange="updatePriority()">
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                </select>
                            </td>
                            <td colspan="2">
                                <span>{% trans "Gravity:" %}</span>
                                <select style="width:50px;" id="grav" onchange="updatePriority()">
                                    <option value="1">1</option>
                                    <option value="2">2</option>
                                    <option value="3">3</option>
                                    <option value="4">4</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th></th>
                            <td colspan="2">{% trans "Total priority:" %} <span id="prio_result">{{report.get_priority}}</span></td>
                        </tr>
                    <tr>
                        <th>
                            <strong>{% trans "Planification:" %}</strong>
                        </th>
                        <td colspan="4">
                            <select id="date_planned" onchange="planned()">
                                {% if not report.planned %}
                                    <option value="">{% trans "Not planned" %}</option>
                                {% endif %}
                                {% for date in report.get_date_planned_available %}
                                    <option value='{{ date|date:"m/Y" }}' {% ifequal date|date:"m/Y" report.date_planned|date:"m/Y" %}selected{% endifequal %}>{{ date|date:"m/Y" }}</option>
                                {% endfor %}
                            </select>
                        </td>
                    </tr>
                    {% else %}
                        <!-- ########################################################### -->
                        <!-- # RESPONSIBLE / ENTITY / EXECUTANT/ IMPETRANT (READ ONLY) # -->
                        <!-- ########################################################### -->
                        <tr>
                            <th><strong>{% trans "Responsible manager:" %}</strong></th>
                            <td>
                                <a href='mailto:{{ report.responsible_department.email }}'>
                                    {{ report.responsible_department.name }}
                                </a>
                                <br/>
                                {{report.responsible_department.dependency.name}}
                            </td>
                        </tr>
                        {% if report.contractor %}
                            <tr>
                                <th><strong>{% trans "Contractor/Applicant:" %}</strong></th>
                                <td>
                                    <p><strong>{{ report.contractor.name }}</strong></p>
                                    {% if not report.contractor %}
                                        -
                                    {% else %}
                                    <ul>
                                        {% for contact_person in report.contractor.workers.all %}
                                            <li>
                                                {{ contact_person.get_full_name }}
                                                {% if contact_person.telephone %}(tel:{{contact_person.telephone}}) {% endif %}
                                             </li>
                                        {% endfor %}
                                    </ul>
                                    {% endif %}
                                </td>
                            </tr>
                        {% endif %}

                        <tr>
                            <th><strong>{% trans "Visibility:" %}</strong></th>
                            <td>
                                {% if report.private %}
                                    {% trans "private" %}
                                {% else %}
                                    {% trans "public" %}
                                {% endif %}
                            </td>
                        </tr>
                        <tr>
                            <th><strong>{% trans "Priority" %}</strong></th>
                            <td colspan="2"><span id="prio_result">{{report.get_priority}}</span></td>
                        </tr>
                        {% if report.planned %}
                            <tr>
                                <th><strong>{% trans "Planned" %}</strong></th>
                                <td colspan="2">{{report.get_date_planned}}</td>
                            </tr>
                        {% endif %}

                    {% endif %}
                {% endif %}
                <tr>
                    <td>&nbsp;</td>
                </tr>
            </table>
        </div>

        <p>
            <a href="{% url 'report_pdf' report.id %}" title="{% trans 'Download a pdf report of this incident' %}">
            <!--i class="icon-download" /--><i class="download-pdf"> </i>{% trans 'report pdf' context 'pro' %}
            </a>

            {% if request.fmsuser.is_pro %}
            <a id='mailPDFCitizenButton' class="btn">{% trans 'mail pdf' %}</a>
            </p>
        <p>
            <span id="mail_pdf_citizen" class="hidden">
                {% trans 'enter mail address' %}
                <textarea id="mail_pdf_emailaddresses_citizen"></textarea>
                <a class="btn pull-right" id="send_pdf_citizen_button">{% trans 'send pdf' %}</a>
                <br>
                {% trans 'enter comment for mail' %}
                <textarea id="mail_pdf_emailcomments_citizen"></textarea>
            </span>
            {% endif %}
        </p>

        {% if request.fmsuser.is_pro %}
            <p><a href="{% url 'report_pdf_pro' report.id %}"><i class="download-pdf-pro"> </i>{% trans 'report pdf pro' %}</a>
                <a id='mailPDFProButton' class="btn">{% trans 'mail pdf' %}</a>
            </p>
            <span id="mail_pdf" class="hidden">
                {% trans 'enter mail address' %}
                <textarea id="mail_pdf_emailaddresses"></textarea>
                <a class="btn pull-right" id="send_pdf_pro_button">{% trans 'send pdf' %}</a>
                <br>
                {% trans 'enter comment for mail' %}
                <textarea id="mail_pdf_emailcomments"></textarea>
            </span>

        {% endif %}

        {% if request.fmsuser.manager or request.fmsuser.leader %}
            <p><a href="{% url 'export_report' 'csv' report.id %}" target="_blank"><i class="download-xls"> </i>{% trans 'Export Csv' %}</a></p>
        {% endif %}

        {% if not report.is_created %}
            <p><a id="show-history" href="#"><i> </i> {% trans 'Show history' %}</a></p>
        {% endif %}

    </div>

    {% if report.attachmentsList %}
        <!-- ########################## -->
        <!-- # DISPLAY FILES AND COMMENTS SECTION  # -->
        <!-- ########################## -->
        <div class="bordered-box">
            {% if report.is_in_progress and report.responsible_department in request.fmsuser.organisations_list %}
                <a href="{% url 'report_validate_all_pro' report.id %}" class="btn pull-right" >{% trans 'Publish all' %}</a>
            {% endif %}

            {% if report.attachmentsList %}
                <h4>{% trans "Photos and files" %}</h4>
                <div id="report_updates">
                    {% for attachment in report.attachmentsList %}
                        {% if not attachment.is_confidential or fms_user.can_see_confidential %}
                            {% include "reports/_attachment.html" with attachment=attachment privacy='private' editable=attachment_edit %}
                        {% endif %}
                    {% endfor %}
                </div>
            {% endif %}

        </div>
    {% endif %}

</div>

<div class="span6">

    {% if not report.is_merged %}
    <!-- ########################## -->
    <!-- # DISPLAY COMMENT FORM   # -->
    <!-- ########################## -->
    <div class="bordered-box">
        <form enctype="multipart/form-data" method="post" action="" id="report-form" class="form-horizontal">
            {% include "reports/_attachments_form.html" with display_citizen_form_comment=False %}

            <div style="overflow:hidden;">
                <input type="submit" class='pull-right btn' value="{% trans 'Save' %}" />
            </div>
        </form>
    </div>
    <div class="bordered-box">
        <h4>{% trans "Subscription" %}</h4>
        <div id="report-subscription">
            <label class="checkbox">
                <input type="checkbox" name="pro-subscription" id="id_pro-subscription"> {% trans "Subscription and report follow-up" %}
            </label>
        </div>
        <!-- #################################### -->
        <!-- # ONLY THE MANAGER CAN USE BUTTONS # -->
        <!-- #################################### -->
        {% if report.responsible_department in request.fmsuser.organisations_list %}
            <button onclick="showNearbyReports();" class="btn" id="btn-merge">{% trans 'Merge' %}</button>
            <!-- ############################################# -->
            <!-- # DISPLAY WHEN REPORT STATUS IS IN PROGRESS # -->
            <!-- ############################################# -->
            {% if report.is_in_progress %}
                {% if request.fmsuser.is_superuser %}
                    <a href="{% url 'report_delete_pro' report.id %}" class="btn pull-right clearfix btn-danger" id="btn-del">{% trans 'Delete' %}</a>
                {% endif %}
                {% if not fms_user.contractor %}
                    <a href="javascript:close();" class="btn pull-right btn-success">{% trans 'Close' %}</a>
                {% endif %}
            {% endif %}
            <!-- ######################################### -->
            <!-- # DISPLAY WHEN REPORT STATUS IS CREATED # -->
            <!-- ######################################### -->
            {% if report.is_created %}
                <a href="{% url 'report_accept_pro' report.id %}" class="btn" >{% trans 'Accept' %}</a>
                <a href="{% url 'report_publish_pro' report.id %}" class="btn">{% trans 'Publish' %}</a>
                <button onclick="refuse();" class="btn pull-right btn-danger">{% trans 'Reject' %}</button>
            {% endif %}
        {% endif %}
        <div style="clear:both;"></div>
    </div>
    {% endif %}

    {% if report.is_markable_as_solved and not report.is_merged%}
        <div class="bordered-box">
             <h4>{% trans "You think this incident is close. Indicate it!" %}</h4>
             <div>
                <button href="#divMarkAsDone" class="pull-right btn" data-toggle="modal" >{% trans 'Solved' %}</button>
            </div>
            <div style="clear:both;"></div>
         </div>
    {% endif %}

</div>
<div id="merge_nearby_reports_popup" class="modal hide fade" role="dialog" style="z-index: 200000">
    <div class="modal-header">
        <a class="close" data-dismiss="modal" aria-hidden="true" >&times;</a>
        <h3>{% trans 'Nearby incidents that are already submitted:' %}</h3>
    </div>
    <div class="modal-body">
        {% if nearby_reports %}
        <div id='search_results'>
            {% for report in nearby_reports %}
                {% include "reports/_selection.html" %}
            {% endfor %}
            <script type="text/javascript">
                var selected;
                function selectReport(id,elem){
                    selected = id;
                    $.each($(elem).parent().children(),function(idx,elem){
                        $(elem).removeClass("selected");<commit_msg>Pro detail : actions (part1)<commit_after>{% extends "reports/show.html" %}
{% load i18n %}
{% load tags %}

{% block script %}
{{ block.super }}

{% block specific_scripts %}
<script src="{{ STATIC_URL }}js/bootstrap-datepicker.js"></script>
<script src="{{ STATIC_URL }}js/locales/bootstrap-datepicker.fr.js"></script>
<script src="{{ STATIC_URL }}js/locales/bootstrap-datepicker.nl.js"></script>
<script src="{{ STATIC_URL }}js/jquery.exif.js"></script>
<link   href="{{ STATIC_URL }}css/datepicker.css" rel="stylesheet" type="text/css"/>

<script type="text/javascript">

var URL_REPORT_REFUSE = "{% url 'report_refuse_pro' report.id %}";

$(function(){
    /**********************************************/
    /* Prepare iphone toogle button look and feel */
    /**********************************************/
    $("input[type=radio]").bind("click",function(){
        var id = $(this).data('attachmentId');
        var level = $(this).val();
        window.location = '{% url "report_update_attachment" report.id %}?attachmentId='+id+'&updateType='+level;
    });

    /***************************/
    /* Set the current manager */
    /***************************/
    $("#report_responsible_manager_select").val("department_{{report.responsible_department.id}}");

    /*************************************************************/
    /* Implement method when changing manager using the dropdown */
    /*************************************************************/
    $("#report_responsible_manager_select").bind("change",function(event){
        var r=confirm("{% trans 'Are you sure you want to change the responsable manager? This action cannot be undone.' %}");
        if (r==true){
            window.location = '{% url "report_change_manager_pro" report.id %}?manId='+$("#report_responsible_manager_select").val();
        }
        else{
            $("#report_responsible_manager_select").val("department_{{report.responsible_department.id}}");
        }
    });
    /******************************/
    /* Set the current contractor */
    /******************************/
    $("#report_responsible_impetrant_contractor_select").val("contractor_{{report.subcontractor.id}}");

    /****************************************************************/
    /* Implement method when changing contractor using the dropdown */
    /****************************************************************/
    $("#report_responsible_impetrant_contractor_select").bind("change",function(event){

        var r=confirm("Are you sure you want to change the contractor/applicant?");
        if (r==true){
            window.location = '{% url "report_change_contractor_pro" report.id %}?contractorId='+$("#report_responsible_impetrant_contractor_select").val();
        }
        else{
            $("#report_responsible_impetrant_contractor_select").val("contractor_{{report.subcontractor.id}}");
        }
    });
    /****************************************************************/
    /* Implement method when clicking private/public checkbox       */
    /****************************************************************/
    $("#id_private").bind("click",function(event){
        var r2=confirm("{% trans 'Are you sure you want to make the incident private? This will notify all public subscribers.' %}");
        if (r2==true){
            window.location = '{% url "report_change_switch_privacy" report.id %}?privacy='+$("#id_private").is(":checked");
        }
        else {
            $('#id_public').attr("checked", "checked");
            window.location = '{{report.get_absolute_url_pro}}';
        }
    });
    $("#id_public").bind("click",function(event){
            window.location = '{% url "report_change_switch_privacy" report.id %}?privacy='+$("#id_private").is(":checked");
    });
    {% if subscribed %}
    $("#id_pro-subscription").attr("value","on").prop('checked', true);
    {% else %}
    $("#id_pro-subscription").attr("value","off");
    {% endif %}

    $("#id_pro-subscription").change(function(){
        if($(this).attr("value")== "on"){
            $(this).attr("value","off");
            $.ajax("{% url 'unsubscribe_pro' report.id %}")
        }
        else{
            $(this).attr("value","on");
            $.ajax("{% url 'subscribe_pro' report.id %}");
        }
    });

    $("#grav").val("{{report.gravity}}");
    $("#prob").val("{{report.probability}}");




});
/* When JQUERY is ready*/
$(document).ready(function() {
    /*Set the contractor dropdown*/
    $('#report_responsible_impetrant_contractor_select').val('{{report.contractor.id}}');
    /*Set the checked value*/
    {% if report.private %}
        $('#id_private').attr("checked", "checked");
    {% else %}
        $('#id_public').attr("checked", "checked");
    {% endif %}
    var markers = [];
    {% for report in reports %}
        var reportJSON = $.extend({}, {{ report.to_JSON|dict_to_json|safe }}, {{ report.marker_detail_JSON|dict_to_json|safe }});

        {% if BACKOFFICE %}
            reportJSON = $.extend(reportJSON, {{ report.marker_detail_pro_JSON|dict_to_json|safe }});
        {%endif%}
        markers.push(fms.currentMap.addReport(reportJSON, {{forloop.counter}}, {% if BACKOFFICE %}true{%else%}false{%endif%}, true));
        fms.currentMap.markersLayer.addFeatures(markers);
    {% endfor %}
    //Clear the comment textarea after each POST
    $("#id_comment-text").val('');

    // False address
    var report_false_adress = "{{ report.false_address }}";

    document.getElementById('mailPDFProButton').addEventListener('click', function() {
        mailbox = document.getElementById('mail_pdf');
        if (mailbox.classList.contains('hidden'))
            mailbox.classList.remove('hidden');
        else
            mailbox.classList.add('hidden');
            document.getElementById('mail_pdf_emailaddresses').value = '';
            document.getElementById('mail_pdf_emailcomments').value ='';
    });

    document.getElementById('mailPDFCitizenButton').addEventListener('click', function() {
        mailbox = document.getElementById('mail_pdf_citizen');
        if (mailbox.classList.contains('hidden'))
            mailbox.classList.remove('hidden');
        else
            mailbox.classList.add('hidden');
            document.getElementById('mail_pdf_emailaddresses_citizen').value = '';
            document.getElementById('mail_pdf_emailcomments_citizen').value ='';
    });



    var isFalseAddressCheckBox = document.getElementById('is_false_address');
    isFalseAddressCheckBox.addEventListener('change', function() {
        var falseAddress_Reason = document.getElementById('false_address');
        if (this.checked) {
            falseAddress_Reason.classList.remove('hidden');
        } else {
            falseAddress_Reason.classList.add('hidden');
        }
    });

    document.getElementById('false_address').addEventListener('keyup', function() {
        if (this.value != report_false_adress) {
            document.getElementById('submit_false_address').classList.remove('hidden');
        } else {
            document.getElementById('submit_false_address').classList.add('hidden');
        }
    });

    document.getElementById('submit_false_address').addEventListener('click', function() {
        // Ajax request to set false_address
        var false_address = document.getElementById('false_address').value;
        var url = '{% url "report_false_address" report.id %}';
        var data = { 'false_address': false_address };

        var self = this;
        $.post( url, data, function( result ) {
            // Do nothing
            self.classList.add('hidden');
            report_false_adress = result;
        });
    });

    document.getElementById("send_pdf_citizen_button").addEventListener('click', function(event){
        $.ajax({
            url:"{% url 'send_pdf' report.id %}",
            data:{"to":$('#mail_pdf_emailaddresses_citizen').val(), "comments":$('#mail_pdf_emailcomments_citizen').val(), "privacy":"public"},
            type:"POST",
            success:function(data){
                alert(data);
                document.getElementById('mailPDFCitizenButton').click();
            }
        });


    });

    document.getElementById("send_pdf_pro_button").addEventListener('click', function(event){
        $.ajax({
            url:"{% url 'send_pdf' report.id %}",
            data:{"to":$('#mail_pdf_emailaddresses').val(), "comments":$('#mail_pdf_emailcomments').val(), "privacy":"private"},
            type:"POST",
            success:function(data){
                alert(data);
                document.getElementById('mailPDFProButton').click();
            }
        });


    });

    $("#main_cat_select").val("{{report.category.id}}");
    $.ajax({
        url:"{% url 'secondary_category_for_main_category' %}?main_category="+"{{report.category.id}}",
        type:"GET",
        success:function(data){
            for(var i = 0; i<data.length;++i){
                {% if report.private %}
                    var option = "<option value='"+data[i].id+"'>"+data[i]["n_"+LANGUAGE_CODE]+"/"+data[i]["s_c_n_"+LANGUAGE_CODE]+"</option>";
                    $("#sec_cat_select").append(option);
                {% else %}
                if(data[i].p === 1){
                    var option = "<option value='"+data[i].id+"'>"+data[i]["n_"+LANGUAGE_CODE]+"/"+data[i]["s_c_n_"+LANGUAGE_CODE]+"</option>";
                    $("#sec_cat_select").append(option);
                }
                {% endif %}
            }
            $("#sec_cat_select").val("{{report.secondary_category.id}}");
        }

    });
    $('#main_cat_select').change(function(){
        if(this.value !== "0"){
            $("#sec_cat_select").removeAttr("disabled");
            $("#sec_cat_select").empty();
            $("#sec_cat_select").append('<option value="0">{% trans "Select a Category" %}</option>');
            $.ajax({
                url:"{% url 'secondary_category_for_main_category' %}?main_category="+this.value,
                type:"GET",
                success:function(data){
                    for(var i = 0; i<data.length;++i){
                        {% if report.private %}
                            var option = "<option value='"+data[i].id+"'>"+data[i]["n_"+LANGUAGE_CODE]+"/"+data[i]["s_c_n_"+LANGUAGE_CODE]+"</option>";
                            $("#sec_cat_select").append(option);
                        {% else %}
                        if(data[i].p === 1){
                            var option = "<option value='"+data[i].id+"'>"+data[i]["n_"+LANGUAGE_CODE]+"/"+data[i]["s_c_n_"+LANGUAGE_CODE]+"</option>";
                            $("#sec_cat_select").append(option);
                        }
                        {% endif %}
                    }

                }
            });
        }
        else {
            $("#sec_cat_select").attr("disabled","disabled");
        }
    });

    $("#sec_cat_select").change(function(){
        $.ajax({
            url:"{% url 'update_category_for_report' report.id %}",
            data:{"main_category":$('#main_cat_select').val(),"secondary_category":this.value},
            type:"POST",
            success:function(data){
                //do nothing
            }
        });
    })

    $($(".update_text").find('#imgtoshow')).exifLoad(someCallback);
});

window.onload = function() {
    // Handle 'I want to create a new report' checkbox
    var createNewReport = document.getElementById('createNewReport');

    if (createNewReport) {
        messageButton.addEventListener('click', function() {
            if (createNewReport.checked) {
                window.location.href = "/";
            }
        });
    }
}

function close(){
    var r=confirm("Are you sure you want to close this report?");
    if (r==true){
        window.location = "{% url 'report_close_pro' report.id %}";
    }
}

function updatePriority(){
    var a = parseInt($("#grav").val());
    var b = parseInt($("#prob").val());
    $.ajax({url:"{% url 'report_update_priority' report.id %}",
        data:{"gravity":a,"probability":b},
        type:'GET',
        datatype:"json",
        success: function(data){
            $("#prio_result").html(data.priority);
        }
    });


}

function showNearbyReports(){
    $("#merge_nearby_reports_popup").modal();
}

function mergeReport(){
    $("#merge_confirm_popup").modal("hide");

    window.location = "{% url 'report_merge_pro' report.id %}?mergeId="+selected;
}
function planned(){
    var date_planned = document.getElementById('date_planned').value;

    if (date_planned) {
        var url = "{% url 'report_planned_pro' report.id %}?date_planned=" + date_planned;
        window.location = url;
    }
}

function showMergeConfirmation(){
    $("#merge_nearby_reports_popup").modal("hide");
    $("#merge_confirm_popup").modal();
}

var someCallback = function(exifObject, index) {
        if (exifObject && exifObject.DateTimeOriginal){
            textAreas = $($(".update_text").find('#imagedate'));
            var datetosplit = exifObject.DateTimeOriginal;
            var splitted = datetosplit.split(/[:,\/ ]/)
            var pictureDate = new Date(splitted[0], splitted[1] -1, splitted[2], splitted[3], splitted[4], splitted[5], 0);
            textAreas[index].innerHTML = splitted[2] + '-' + splitted[1] + '-' + splitted[0] + " " +splitted[3] + ":" +splitted[4];
            }
        }



</script>
<script src="{{ STATIC_URL}}js/reports_show_pro.js"></script>
{% endblock %}
{% endblock %}

{% block css %}
{{ block.super }}
{% endblock %}

{% block map %}
<div class="container">
    <div class="row">
        <div class="span12">
            <article id="map" class="view_incident">
                <div id="incident-head">
                    <div class="row">
                        <div class="span3">
                            <div class="ticket_infos">
                                <span class="ticket_number">
                                    <img src="{{STATIC_URL}}{{ report.get_marker}}" /> {% trans 'Incident n°' %} {{ report.get_ticket_number }}
                                </span><br />
                                <span class="ticket_address">
                                    {{ report.address }}, {{ report.address_number }}<br />
                                    {{ report.postalcode }} {{ report.get_address_commune_name }}
                                </span><br />
                                <span class="ticket_desc">
                                    {{ report.display_category }}
                                </span>
                            </div>
                        </div>
                        <div class="span6">
                            timeline

                            <!-- Actions -->
                            <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel" style="display:block">
                                <li class="dropdown-submenu">
                                     <a tabindex="-1" href="#">{% trans 'Choisir une action' %}</a>
                                     <ul class="dropdown-menu">
                                        {% if report.responsible_department in request.fmsuser.organisations_list and not report.is_merged %}
                                            <li class="dropdown-submenu">
                                                <a tabindex="-1" href="#">Transférer à</a>
                                                <ul class="dropdown-menu">
                                                    <li class="dropdown-submenu">
                                                        <a tabindex="-1" href="#">{% trans 'Gestionnaires' %}</a>
                                                        <ul class="dropdown-menu">
                                                            {% for department in departments %}
                                                                <li>
                                                                    <a tabindex="-1" href="{% url 'report_change_manager_pro' report.id %}?manId=department_{{department.id}}">
                                                                        {{department.name}} ({{ department.dependency.name}})
                                                                    </a>
                                                                </li>
                                                            {% endfor %}
                                                        </ul>
                                                    </li>
                                                    <li class="dropdown-submenu">
                                                        <a tabindex="-1" href="#">{% trans 'Entites' %}</a>
                                                        <ul class="dropdown-menu">
                                                            {% for entity in entities %}
                                                                <li>
                                                                    <a tabindex="-1" href="{% url 'report_change_manager_pro' report.id %}?manId=entity_{{entity.id}}">
                                                                        {{entity.name}}
                                                                    </a>
                                                                </li>
                                                            {% endfor %}
                                                        </ul>
                                                    </li>
                                                    <li class="dropdown-submenu">
                                                        <a tabindex="-1" href="#">{% trans 'Organisms' %}</a>
                                                        <ul class="dropdown-menu">
                                                            {% for institution in region_institution %}
                                                                <li>
                                                                    <a tabindex="-1" href="{% url 'report_change_manager_pro' report.id %}?manId=entity_{{institution.id}}">
                                                                        {{institution.name}}
                                                                    </a>
                                                                </li>
                                                            {% endfor %}
                                                        </ul>
                                                    </li>

                                                </ul>
                                            </li>

                                            <li class="dropdown-submenu">
                                                <a tabindex="-1" href="#">Assigner à</a>
                                                <ul class="dropdown-menu">
                                                    <li class="dropdown-submenu">
                                                        <a tabindex="-1" href="#">Impétrants</a>
                                                        <ul class="dropdown-menu">
                                                            {% for organisation in contractors %}
                                                                <li>
                                                                    <a tabindex="-1" href="{% url 'report_change_contractor_pro' report.id %}?contractorId={{organisation.id}}">
                                                                        {{ organisation.name }}
                                                                    </a>
                                                                </li>
                                                            {% endfor %}
                                                        </ul>
                                                    </li>
                                                    <li class="dropdown-submenu">
                                                        <a tabindex="-1" href="#">Exécuteurs</a>
                                                        <ul class="dropdown-menu">
                                                            {% for applicant in applicants %}
                                                                <li>
                                                                    <a tabindex="-1" href="{% url 'report_change_contractor_pro' report.id %}?contractorId={{applicant.id}}">
                                                                        {{ applicant.name }}
                                                                    </a>
                                                                </li>
                                                            {% endfor %}
                                                        </ul>
                                                    </li>
                                                </ul>
                                            </li>
                                        {% endif %}

                                    <!--  Planification -->
                                        <li class="dropdown-submenu">
                                            <a tabindex="-1" href="#">Planifier</a>

                                        <!-- Dates possible de planification -->
                                            <ul class="dropdown-menu">

                                                {% if not report.planned %}
                                                    <li class="active">
                                                        <a tabindex="-1" href="#">{% trans "Not planned" %}</a>
                                                    </li>
                                                {% endif %}
                                                {% for date in report.get_date_planned_available %}
                                                    <li {% ifequal date|date:"m/Y" report.date_planned|date:"m/Y" %}class="active"{% endifequal %}>
                                                        <a tabindex="-1" href="{% url 'report_planned_pro' report.id %}?date_planned={{ date|date:"m/Y" }}">
                                                            {{ date|date:"m/Y" }}
                                                        </a>
                                                    </li>
                                                {% endfor %}

                                            </ul>
                                        </li>
                                        <li>
                                            <a tabindex="-1" href="#">Fusionner</a>
                                        </li>
                                        <li>
                                            <a tabindex="-1" href="#modalPriority" data-toggle="modal">Priorité</a>
                                        </li>

                                        {% if not fms_user.contractor %}
                                            <li>
                                                <a href="javascript:close();">{% trans 'Close' %}</a>
                                            </li>
                                        {% endif %}
                                    </ul>
                                </li>
                        </div>
                        <div class="span3">
                            {% if report.is_in_progress %}
                                {% if report.status != report.SOLVED %}
                                    <a href="#divMarkAsDone" role="button" class="btn lk-isresolved" data-toggle="modal">
                                        <i class="isresolved"> </i>{% trans "Signaler résolu" %}
                                    </a>
                                {% endif %}

                                {% if not report.is_closed and not subscribed %}
                                    <a href="#modalSubscription" role="button" class="btn lk-subscribe" data-toggle="modal">
                                        {% if report.subscriptions.all.count %}
                                            <span class="badge badge-inverse">{{ report.subscriptions.all.count }}</span>
                                        {% endif %}
                                        <i class="subscribe"> </i>

                                        {% trans "S'abonner" %}
                                    </a>
                                {% endif %}
                            {% endif %}

                            <a class="lk-download-pdf btn" href="#modalDownloadPDF" title="{% trans 'Download a pdf report of this incident' %}" data-toggle="modal">
                                <!--i class="icon-download" /--><i class="download-pdf"> </i>{% trans 'Télécharger' %}
                            </a>
                        </div>
                    </div>
                </div>
                <div id="copyright-urbis">Realized by means of Brussels UrbIS®©</div>
                <div id="btn-pulldownmap"><a href="#"><i class="icon-pulldownmap"></i>{% trans "Agrandir la carte" %}</a></div>
                <div id="btn-streetview"><a href="#"><i class="icon-streetview"></i>{% trans "Street View" %}</a></div>
            </article>
        </div>
    </div>
</div>
{% endblock %}

{% block content %}
<!-- Modal -->
{% if report.is_in_progress %}
    {% if report.status != report.SOLVED %}
        <div id="divMarkAsDone" class="modal hide fade">
            <form id="dialogMarkAsDone" title="Please enter more information about marking the report as done" action="{% url 'report_fix_pro' report.id %}?is_fixed=True" method="post" >
                {% csrf_token %}

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h3>{% trans "You think this incident is close. Indicate it!" %}</h3>
                </div>
                <div class="modal-body">
                    <p>{% trans 'Indicate that the incident is fixed. By pressing this button a mail will be send to the responsible manager.' %}</p>
                    {{ mark_as_done_form.as_p }}
                    <input id="subscribe-incident-show-report" type="submit" class="btn  btn-primary"  value="{% trans 'Confirm'%}"/>
                </div>

                <!--div class="modal-footer">
                    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
                </div-->
            </form>
        </div>
    {% endif %}

    {% if not report.is_closed and not subscribed %}
        <div id="modalSubscription" class="modal hide fade">
            <form id="citizen-subscription-form" action="{% url 'subscribe' report.id %}">
                {% csrf_token %}

                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h3>{% trans "Subscription:" %}</h3>
                </div>
                <div class="modal-body">
                    <p>
                    {% blocktrans with count=report.subscriptions.count %}
                        Subscribe to receive notifications ({{ count }} subscribers to this incident)
                    {% endblocktrans %}
                    </p>

                    <div id="report-subscription">
                        <label class="checkbox">
                            <input type="checkbox" name="pro-subscription" id="id_pro-subscription"> {% trans "Subscription and report follow-up" %}
                        </label>
                    </div>
                </div>

                <!--div class="modal-footer">
                    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
                </div-->
            </form>
        </div>
    {% endif %}

    <div id="modalPriority" class="modal hide fade">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h3>{% trans "Priority:" %}</h3>
        </div>
        <div class="modal-body">
            <tr>
                <td colspan="2">
                    <span>{% trans "Probability:" %}</span>
                    <select style="width:50px;" id="prob" onchange="updatePriority()">
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                    </select>
                </td>
                <td colspan="2">
                    <span>{% trans "Gravity:" %}</span>
                    <select style="width:50px;" id="grav" onchange="updatePriority()">
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th></th>
                <td colspan="2">{% trans "Total priority:" %} <span id="prio_result">{{report.get_priority}}</span></td>
            </tr>
        </div>

        <!--div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        </div-->
    </div>

{% endif %}
<div id="modalDownloadPDF" class="modal hide fade">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h3>{% trans 'Download a pdf report of this incident' %}</h3>
        </div>

        <div class="modal-body">

            <p>
                <a href="{% url 'report_pdf' report.id %}" title="{% trans 'Download a pdf report of this incident' %}">
                <!--i class="icon-download" /--><i class="download-pdf"> </i>{% trans 'report pdf' context 'pro' %}
                </a>

                {% if request.fmsuser.is_pro %}
                <a id='mailPDFCitizenButton' class="btn">{% trans 'mail pdf' %}</a>
                </p>
            <p>
                <span id="mail_pdf_citizen" class="hidden">
                    {% trans 'enter mail address' %}
                    <textarea id="mail_pdf_emailaddresses_citizen"></textarea>
                    <a class="btn pull-right" id="send_pdf_citizen_button">{% trans 'send pdf' %}</a>
                    <br>
                    {% trans 'enter comment for mail' %}
                    <textarea id="mail_pdf_emailcomments_citizen"></textarea>
                </span>
                {% endif %}
            </p>

            {% if request.fmsuser.is_pro %}
                <p><a href="{% url 'report_pdf_pro' report.id %}"><i class="download-pdf-pro"> </i>{% trans 'report pdf pro' %}</a>
                    <a id='mailPDFProButton' class="btn">{% trans 'mail pdf' %}</a>
                </p>
                <span id="mail_pdf" class="hidden">
                    {% trans 'enter mail address' %}
                    <textarea id="mail_pdf_emailaddresses"></textarea>
                    <a class="btn pull-right" id="send_pdf_pro_button">{% trans 'send pdf' %}</a>
                    <br>
                    {% trans 'enter comment for mail' %}
                    <textarea id="mail_pdf_emailcomments"></textarea>
                </span>

            {% endif %}

            {% if request.fmsuser.manager or request.fmsuser.leader %}
                <p><a href="{% url 'export_report' 'csv' report.id %}" target="_blank"><i class="download-xls"> </i>{% trans 'Export Csv' %}</a></p>
            {% endif %}

        </div>

        <!--div class="modal-footer">
            <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        </div-->
</div>

<div id="divRefuse" class="modal hide fade" role="dialog">
    <div class="modal-body">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <form id="dialog" title="Please enter more information about rejecting the report" action="{% url 'report_refuse_pro' report.id %}" method="post">
            {% include "_form_horizontal.html" with form=refuse_form %}
            <input type="button" class="btn"  value="{% trans 'Cancel'%}" data-dismiss="modal" aria-hidden="true"/>
            <input type="submit" class="btn"  value="{% trans 'Confirm'%}"/>
        </form>
    </div>
</div>

<div id="history_popup" class="modal hide fade" role="dialog">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h2>{% trans 'History' %} {% trans 'incident '%} {{report.get_ticket_number}}</h2>
    </div>
    <div class="modal-body">
        {% include "reports/_activity_list.html" with  privacy='private' %}
    </div>
    <div class="modal-footer">
        <input type="button" class="btn"  value="{% trans 'OK'%}" data-dismiss="modal" aria-hidden="true"/>
    </div>
</div>

<h1 class="span12">
    {% if report.is_in_progress %}
        <img src="{{STATIC_URL}}{{report.get_marker}}" style="max-width:30px;" />
    {% else %}
        <img src="{{STATIC_URL}}{{report.get_marker}}" style="max-width:30px;" />
    {% endif %}
    {% trans "Report Ticket" %} {{ report.get_ticket_number }}
</h1>

<div class="span6">
    <div class="bordered-box">
        {% if not report.is_merged %}
            {% if report.is_created %}
                <div class='is_created'>{% trans "This incident is not validated." %}</div>
            {% endif %}

            {% if report.is_refused %}
                <div class='is_created'>
                    <p>{% trans "This problem has been refused." %}</p>
                    <p>{{ report.refusal_motivation }}</p>
                </div>
            {% endif %}

            {% if report.is_in_progress %}
                <div class="is_in_progress">{% trans "This incident is in progress." %}</div>
            {% endif %}

            {% if report.is_closed %}
                <div class='is_fixed'>{% trans "This incident has been closed." %}</div>
            {% endif %}
        {% else %}
            <div class='is_fixed'>{% trans "This report has been merged with report: " %}<a href="{{report.merged_with.get_absolute_url_pro}}" >{{report.merged_with.get_ticket_number}}</a></div>
        {% endif %}
        <div id='report-body'>
            <p>
                {% if report.description %}
                    {{report.description|linebreaks}}
                {% endif %}
            </p>
            <p class="author-sign">
                {% if report.citizen %}
                    <!-- Protect privacy from applicant and contractor when creator is a citizen -->
                    {% if fms_user.can_see_confidential %}
                        {% if report.citizen.last_name = ''%}
                            {% blocktrans with by=report.citizen.last_name on=report.created|date mail=report.citizen.email %}
                                Posted by <strong><a href='mailto:{{mail}}'>ANONYMOUS</a></strong> on <strong>{{on}}</strong>
                            {% endblocktrans %}
                        {% else %}
                            {% blocktrans with by=report.citizen.last_name on=report.created|date mail=report.citizen.email %}
                                Posted on <strong>{{on}}</strong> by <strong><a href='mailto:{{mail}}'>{{by}}</a></strong>
                            {% endblocktrans %}
                            (tel:{{report.citizen.fmsuser.telephone}})
                        {% endif %}
                    {% else %}
                        {% blocktrans with on=report.created %}
                            Posted on <strong>{{on}}</strong>
                        {% endblocktrans %}
                   {% endif %}
               {% else %}
                   {% blocktrans with by=report.created_by.get_full_name on=report.created mail=report.created_by.email %}
                        Posted by <strong><a href='mailto:{{mail}}'>{{by}}</a></strong> on <strong>{{on}}</strong>
                   {% endblocktrans %}
                   (tel:{{report.created_by.fmsuser.telephone}})
               {% endif %}
            </p>

            <!-- ################## -->
            <!-- # REPORT DETAILS # -->
            <!-- ################## -->
            <table id='report-status'>
                <tr>
                    <th><strong>{% trans "Location:" %}</strong></th>
                    <td colspan="3">{{report.address}}, {{report.address_number}} ({{report.postalcode}} {{report.get_address_commune_name}})</td>
                </tr>

                {% if report.responsible_department in request.fmsuser.organisations_list and not report.is_merged %}
                <tr>
                    <th><strong>{% trans "Wrong address:" %}</strong></th>
                    <td colspan="2"><textarea id="false_address" name="false_address" {% if not report.false_address %}class="hidden"{% endif %}>{% if report.false_address %}{{ report.false_address }}{% endif %}</textarea></td>
                    <td colspan="1"><input type="checkbox" id="is_false_address" {% if report.false_address %}checked{% endif %}></td>
                    <td colspan="1"><span id="submit_false_address" class="btn hidden" style="float:right;">Valider</span></td>
                </tr>
                {% else %}
                    {% if report.false_address %}
                        <tr>
                            <th><strong>{% trans "Wrong address:" %}</strong></th>
                            <td colspan="2">{{report.false_address}}</td>
                        </tr>
                    {% endif %}
                {% endif %}
                {% if report.responsible_department in request.fmsuser.organisations_list and report.is_in_progress and not report.is_merged %}
                <tr>
                    <th><strong>{% trans "Category:" %}</strong></th>
                    <td colspan="4">
                            <select id="main_cat_select">
                                <option value="0">{% trans "Select a Category" %}</option>
                                {% for cat in category_list%}
                                    <option value="{{cat.id}}">{{cat.name}}</option>
                                {% endfor %}
                            </select>
                    </td>
                </tr>
                <tr>
                    <th><strong>{% trans "Secondary category:" %}</strong></th>
                    <td colspan="4">
                        <select id="sec_cat_select"><option value="0">{% trans "Select a Category" %}</option></select>
                    </td>
                </tr>
                {% else %}
                <tr>
                    <th><strong>{% trans "Category:" %}</strong></th>
                    <td colspan="4">
                    {{report.display_category}}
                    </td>
                </tr>
                {% endif %}
                <tr>
                    <th><strong>{% trans "Status:" %}</strong></th>
                    <td>{{ report.get_status_display }}</td>
                </tr>

                {% if not report.is_in_progress %}
                <tr>
                    <th><strong>{% trans "Responsible:" %}</strong></th>
                    <td>{{ report.responsible_department.name }} ({{report.responsible_department.dependency.name}})</td>
                </tr>
                {% endif %}

                {% if report.is_in_progress %}
                    {% if report.responsible_department in request.fmsuser.organisations_list and not report.is_merged %}
                        <!-- ################################# -->
                        <!-- # CONTRACTOR/IMPETRANT DROPDOWN # -->
                        <!-- ################################# -->
                        <tr>
                            <th><strong>{% trans "Contractor/Applicant:" %}</strong></th>
                            <td colspan="4">
                                {% if report.contractor %}
                                <ul>
                                    {% for contact_person in report.contractor.workers.all %}
                                        <li>
                                            {{ contact_person.get_full_name }}
                                            {% if contact_person.telephone %}(tel:{{contact_person.telephone}}) {% endif %}
                                         </li>
                                    {% endfor %}
                                </ul>
                                {% endif %}
                            </td>
                        </tr>
                        <!-- ################################# -->
                        <!-- # PUBLIC OR PRIVATE CHECKBOX    # -->
                        <!-- ################################# -->
                        <tr>
                            <th>
                                <strong>{% trans "Visibility:" %}</strong>
                            </th>
                            <td colspan="2">
                                <input type="radio" id="id_private" name="public_private">
                                {% trans "Private" %}
                            </td>
                            <td colspan="2">
                                <input type="radio" id="id_public" name="public_private">
                                {% trans "Public" %}
                            </td>
                        </tr>
                    {% else %}
                        <!-- ########################################################### -->
                        <!-- # RESPONSIBLE / ENTITY / EXECUTANT/ IMPETRANT (READ ONLY) # -->
                        <!-- ########################################################### -->
                        <tr>
                            <th><strong>{% trans "Responsible manager:" %}</strong></th>
                            <td>
                                <a href='mailto:{{ report.responsible_department.email }}'>
                                    {{ report.responsible_department.name }}
                                </a>
                                <br/>
                                {{report.responsible_department.dependency.name}}
                            </td>
                        </tr>
                        {% if report.contractor %}
                            <tr>
                                <th><strong>{% trans "Contractor/Applicant:" %}</strong></th>
                                <td>
                                    <p><strong>{{ report.contractor.name }}</strong></p>
                                    {% if not report.contractor %}
                                        -
                                    {% else %}
                                    <ul>
                                        {% for contact_person in report.contractor.workers.all %}
                                            <li>
                                                {{ contact_person.get_full_name }}
                                                {% if contact_person.telephone %}(tel:{{contact_person.telephone}}) {% endif %}
                                             </li>
                                        {% endfor %}
                                    </ul>
                                    {% endif %}
                                </td>
                            </tr>
                        {% endif %}

                        <tr>
                            <th><strong>{% trans "Visibility:" %}</strong></th>
                            <td>
                                {% if report.private %}
                                    {% trans "private" %}
                                {% else %}
                                    {% trans "public" %}
                                {% endif %}
                            </td>
                        </tr>
                        <tr>
                            <th><strong>{% trans "Priority" %}</strong></th>
                            <td colspan="2"><span id="prio_result">{{report.get_priority}}</span></td>
                        </tr>
                        {% if report.planned %}
                            <tr>
                                <th><strong>{% trans "Planned" %}</strong></th>
                                <td colspan="2">{{report.get_date_planned}}</td>
                            </tr>
                        {% endif %}

                    {% endif %}
                {% endif %}
                <tr>
                    <td>&nbsp;</td>
                </tr>
            </table>
        </div>

        {% if not report.is_created %}
            <p><a id="show-history" href="#"><i> </i> {% trans 'Show history' %}</a></p>
        {% endif %}

    </div>

    {% if report.attachmentsList %}
        <!-- ########################## -->
        <!-- # DISPLAY FILES AND COMMENTS SECTION  # -->
        <!-- ########################## -->
        <div class="bordered-box">
            {% if report.is_in_progress and report.responsible_department in request.fmsuser.organisations_list %}
                <a href="{% url 'report_validate_all_pro' report.id %}" class="btn pull-right" >{% trans 'Publish all' %}</a>
            {% endif %}

            {% if report.attachmentsList %}
                <h4>{% trans "Photos and files" %}</h4>
                <div id="report_updates">
                    {% for attachment in report.attachmentsList %}
                        {% if not attachment.is_confidential or fms_user.can_see_confidential %}
                            {% include "reports/_attachment.html" with attachment=attachment privacy='private' editable=attachment_edit %}
                        {% endif %}
                    {% endfor %}
                </div>
            {% endif %}

        </div>
    {% endif %}

</div>

<div class="span6">

    {% if not report.is_merged %}
    <!-- ########################## -->
    <!-- # DISPLAY COMMENT FORM   # -->
    <!-- ########################## -->
    <div class="bordered-box">
        <form enctype="multipart/form-data" method="post" action="" id="report-form" class="form-horizontal">
            {% include "reports/_attachments_form.html" with display_citizen_form_comment=False %}

            <div style="overflow:hidden;">
                <input type="submit" class='pull-right btn' value="{% trans 'Save' %}" />
            </div>
        </form>
    </div>
    <div class="bordered-box">
        <!-- #################################### -->
        <!-- # ONLY THE MANAGER CAN USE BUTTONS # -->
        <!-- #################################### -->
        {% if report.responsible_department in request.fmsuser.organisations_list %}
            <button onclick="showNearbyReports();" class="btn" id="btn-merge">{% trans 'Merge' %}</button>
            <!-- ######################################### -->
            <!-- # DISPLAY WHEN REPORT STATUS IS CREATED # -->
            <!-- ######################################### -->
            {% if report.is_created %}
                <a href="{% url 'report_accept_pro' report.id %}" class="btn" >{% trans 'Accept' %}</a>
                <a href="{% url 'report_publish_pro' report.id %}" class="btn">{% trans 'Publish' %}</a>
                <button onclick="refuse();" class="btn pull-right btn-danger">{% trans 'Reject' %}</button>
            {% endif %}
        {% endif %}
        <div style="clear:both;"></div>
    </div>
    {% endif %}

</div>
<div id="merge_nearby_reports_popup" class="modal hide fade" role="dialog" style="z-index: 200000">
    <div class="modal-header">
        <a class="close" data-dismiss="modal" aria-hidden="true" >&times;</a>
        <h3>{% trans 'Nearby incidents that are already submitted:' %}</h3>
    </div>
    <div class="modal-body">
        {% if nearby_reports %}
        <div id='search_results'>
            {% for report in nearby_reports %}
                {% include "reports/_selection.html" %}
            {% endfor %}
            <script type="text/javascript">
                var selected;
                function selectReport(id,elem){
                    selected = id;
                    $.each($(elem).parent().children(),function(idx,elem){
                        $(elem).removeClass("selected");
{'fraction_non_alphanumeric': 0.1754177132248553, 'fraction_numerical': 0.0022824069018237414, 'mean_word_length': 1.3938879012862073, 'pattern_counts': {'":': 26, '<': 1212, '<?xml version=': 0, '>': 1208, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 413, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1461433', 'n_tokens_mistral': 23857, 'n_tokens_neox': 21667, 'n_words': 4186}