contacts.html 4.85 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
{% extends "edumanage/welcome.html"%}
			{% block crumbs %}
	    			<li><a href="{% url manage %}">Home</a><span class="divider">/</span></li>
	    			<li class="active">Contacts</li>
	    			{% endblock %}
{% load i18n %}
{% block extrahead %}
<script type="text/javascript" src="/static/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/static/js/datatables_bootstrap.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	 {% if contacts %}
var oTable = $('#table').dataTable({
	"sPaginationType": "bootstrap",
	"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
	"aoColumns": [{
        "bSearchable": true,
        "bSortable": true
    }, {
        "bSearchable": true,
        "bSortable": true
    }, {
        "bSearchable": true,
        "bSortable": true
    }, {
        "bVisible": true,
        "bSearchable": false,
        "bSortable": false
    }],
    "aaSorting": [[0, 'desc']],
    "iDisplayLength": 25,
    "oSearch": {"bSmart": false, "bRegex":true},
    "oLanguage": {
    	"sLengthMenu": '{% trans "Display" %} <select><option value="25">25</option><option value="50">50</option><option value="-1">{% trans "All" %}</option></select> {% trans "contacts" %}',
        "sProcessing":   "Processing...",
        "sZeroRecords": '{% trans "No records to display" %}',
        "sInfo":         "Showing _START_ to _END_ of _TOTAL_ entries",
        "sInfoEmpty":    "{% trans "Showing 0 to 0 of 0 entries" %}",
        "sInfoFiltered": "(filtered from _MAX_ total entries)",
        "sInfoPostFix":  "",
        "sSearch":       '{% trans "Search:" %}',
        "sUrl":          "",
        "oPaginate": {
            "sFirst":    '{% trans "First" %}',
            "sPrevious": '{% trans "Previous" %}',
            "sNext":     '{% trans "Next" %}',
            "sLast":     '{% trans "Last" %}'
        }
    }
});

oTable.fnDraw();

$('[id^=del_contact_]').click(function(){
	contact_id = (this.id).replace("del_contact_", '');
	name = this.getAttribute("data-contactname");
	$("#mymodalbody").html("You are about to delete contact: <b>"+name+"</b><br>Press Delete to proceed or Cancel to cancel deletion");
	$("#myModalLabel").html("Delete contact "+name);
	$('#myModal').modal('show');
	$(".modal-footer").show();
	$("#contact_name_del").html(name)	
	return false;
});

$("#delcontactSubmit").click(function(){
	$.ajax({
		url:"{% url del-contact %}/?contact_pk="+contact_id,
		type: "GET",
		success: function(data){
			if (data.error){
				$(".modal-footer").hide();
				$("#mymodalbody").html("<font style='color:#B94A48'>"+data.error+"</font>");
			}
			if (data.success){
				$(".modal-footer").hide();
				$("#mymodalbody").html("contact "+name+" successfully deleted");
				window.setTimeout('location.reload()', 1000);
				
			}
			}
		});
});

{% endif %}
});
</script>
{% endblock %}

	{% block navbar %}
			
    		{% endblock %}
    		
    		{% block homeactive %}{% endblock %}
    		{% block contactsactive %}class="active"{% endblock %}
            {% block subcontent %}

	            	
	              <h4>contacts</h4>
	              <hr>
	              <div><a href="{% url edit-contacts %}" class="btn btn-primary">Add new contact</a></div>
	              <div class="span10"></div>
	              {% if contacts %}
	              <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" width="100%" id="table">
					<thead>
					<tr>
						<th>Name</th>
						<th>Email</th>
						<th>Phone</th>
						<th style="text-align: center;">Action</th>
					</tr>
					</thead>
					
					<tbody>
	                {% for contact in contacts %}
	              	<tr class="GradeC">
	                	<td>{{contact.firstname}} {{contact.lastname}}</td>
	                	<td>{{contact.email}}</td>
	                	<td>{{contact.phone}}</td>
	                	<td style="text-align: center;"><a href="{% url edit-contacts contact.pk %}" class="btn btn-small">edit</a> <a href="#" id="del_contact_{{contact.pk}}" data-contactname="{{contact.firstname}} {{contact.lastname}}" class="btn btn-small btn-warning">delete</a></td>
	                </tr>
	              	{% endfor %}
	              	</tbody>
	              </table>
	              {% else %}
	              <div>No contacts defined yet (<a href="{% url edit-contacts %}">add</a>)</div>
	              {% endif %}
<div class="modal hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Delete contact</h3>
</div>
<div class="modal-body" id="mymodalbody">

</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
<a class="btn btn-warning" id="delcontactSubmit" href="#">Delete</a>
</div>
</div>
            {% endblock %}