cciw-website / templates / cciw / officers / manage_crbs.html

{% extends "cciw/officers/base.html" %}
{% load url from future %}
{% block content %}
<script type="text/javascript">
function CRBFormSent(officerId) {
    jQuery.ajax({
        type: "POST",
        url: "{% url 'cciw.officers.views.mark_crb_sent' %}",
        data: "officer_id=" + officerId.toString(),
        dataType: 'json',
        success: function(data) {
            // We need undo information, and we need to update the 'CRB form
            // sent' column. We store undo information in a stack, on the undo
            // button itself.
            var btn = jQuery('#id_undo_' + officerId.toString());
            var lastSentCell = jQuery('#id_last_crb_form_sent_' + officerId.toString());
            var highlightDiv = jQuery('#id_highlightdiv_' + officerId.toString());
            if (btn.data('undoIdList') == null) {
                btn.data('undoIdList', new Array);
            }
            if (btn.data('undoLastSentList') == null) {
                btn.data('undoLastSentList', new Array);
            }
            var undoIdList = btn.data('undoIdList');
            var undoLastSentList = btn.data('undoLastSentList');
            undoIdList.push(data.crbFormLogId);
            undoLastSentList.push(lastSentCell.html());
            lastSentCell.html('Just now');
            highlightDiv.removeClass("actionable");

            // Add callback to undo button
            btn.unbind();
            btn.click(function() {
                // Delete server side
                jQuery.ajax({
                    type: "POST",
                    url: "{% url 'cciw.officers.views.undo_mark_crb_sent' %}",
                    data: "crbformlog_id=" + undoIdList.pop().toString(),
                    dataType: 'json'
                });
                // Fix up cell client side
                var lastSentCellContents = undoLastSentList.pop();
                lastSentCell.html(lastSentCellContents);
                if (undoIdList.length == 0) {
                    btn.hide();
                }
                if (lastSentCellContents.replace(/\n|\r| /g, '') == "") {
                    highlightDiv.addClass("actionable");
                }

            });
            btn.show();
        }
    });
}

function alertLeadersCrbConsentCheck(applicationId) {
    window.open("{% url 'cciw.officers.views.crb_consent_problem' %}?application_id=" + applicationId.toString(),
                '_blank',"toolbar=yes,height=600,width=900,location=yes,menubar=yes,scrollbars=yes,resizable=yes");

}
</script>

<h1>Manage CRBs</h1>

<p>This pages shows all officers on camps, year {{ year }}, and their status
regarding needing CRB forms.</p>

<p>For officers needing CRBs:</p>

<ul>
  <li>Use 'Show address' to view the officer's address (from application form)</li>
  <li>Use the buttons in the 'Manage' column to indicate you've physically sent them a CRB form to fill in.</li>
  <li>Officers most likely to need attention are <span class="actionable">highlighted</span>.</li>
</ul>

<p>To enter information for CRBs that have been <em>completed</em>, use the <a href="{% url 'admin:officers_crbapplication_changelist' %}">CRB Disclosures admin</a>.</p>

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Camps</th>
      <th>Application form</th>
      <th>CRB</th>
      <th>CRB form sent</th>
      <th>Address</th>
      <th>Manage</th>
    </tr>
  </thead>
  <tbody>
    {% for officer in all_officers %}
      <tr id="id_highlightdiv_{{ officer.id }}" {% if not officer.temp.has_valid_crb and officer.temp.has_application_form and not officer.temp.last_crb_form_sent %}class="actionable"{% endif %}>
        <td>{{ officer.first_name }} {{ officer.last_name }}</td>
        <td>{% for camp in officer.temp.camps %}
              <a href="{% url 'cciw.officers.views.officer_list' year=camp.year number=camp.number %}">{{ camp.number }}</a>{% if not forloop.last %}, {% endif %}
            {% endfor %}
        </td>
        <td>{% if officer.temp.has_application_form %}<img src="{{ STATIC_URL }}admin/img/admin/icon-yes.gif"> <a href="{% url 'admin:officers_application_change' officer.temp.application_id %}" rel="external">View/edit</a>{% endif %}</td>
        <td>{% if not officer.temp.has_crb %}<img src="{{ STATIC_URL }}admin/img/admin/icon_error.gif"> Never{% else %}{% if officer.temp.has_valid_crb %}<img src="{{ STATIC_URL }}admin/img/admin/icon_success.gif"> Recent{% else %}<img src="{{ STATIC_URL }}admin/img/admin/icon_alert.gif"> Out of date{% endif %}{% endif %}</td>
        <td id="id_last_crb_form_sent_{{ officer.id }}">
          {% if officer.temp.has_valid_crb %}
            n/a
          {% else %}
            {% if officer.temp.last_crb_form_sent %}
              {{ officer.temp.last_crb_form_sent|timesince }} ago
            {% endif %}
          {% endif %}
        </td>
        <td>
          {% if not officer.temp.has_valid_crb %}
            {% if officer.temp.has_application_form %}
              {% if officer.temp.crb_check_consent %}
                <a href="javascript:void(0)" onclick="$('#id_address_{{ officer.id }}').toggle();">Show address</a> <span class="address" style="display:none;" id="id_address_{{ officer.id }}">{{ officer.temp.address }}</span>
              {% else %}
                <b>Officer does not<br/> consent to CRB check.<br/></b>
                <button onclick="alertLeadersCrbConsentCheck({{ officer.temp.application_id }})">Alert leaders</button>
              {% endif %}
            {% else %}
              Needs application form
            {% endif %}
          {% endif %}
        </td>
        <td>
          {% if not officer.temp.has_valid_crb and officer.temp.has_application_form and officer.temp.crb_check_consent %}
            <button onclick="CRBFormSent({{ officer.id }});">Click when sent</button>
            <button id="id_undo_{{ officer.id }}" style="display: none;">Undo</button>
          {% endif %}
        </td>
      </tr>
    {% endfor %}
  </tbody>
</table>
{% endblock %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.