|
| 1 | +{% extends "base.html" %} |
| 2 | +{% load i18n humanize %} |
| 3 | +{% load staticfiles %} |
| 4 | +{% load crispy_forms_tags %} |
| 5 | + |
| 6 | +{% block content %} |
| 7 | +<table id="issue-ticket" class="table table-hover"> |
| 8 | +<thead> |
| 9 | + <tr> |
| 10 | + <th>이름</th> |
| 11 | + <th>이메일</th> |
| 12 | + <th>관리</th> |
| 13 | + </tr> |
| 14 | +</thead> |
| 15 | +<tbody> |
| 16 | + {% for user in registration %} |
| 17 | + <tr> |
| 18 | + <td>{{ user.name }}</td> |
| 19 | + <td>{{ user.email }}</td> |
| 20 | + <td> |
| 21 | + <div class="btn-group"> |
| 22 | + <button type="button" class="btn btn-success btn-filter" onclick="printLabelPopup('{{ user.name }}', {{ user.id }},'{{ user.top_size }}')">발권</button> |
| 23 | + <a class="btn btn-default btn-filter" |
| 24 | + href='/admin/registration/registration/{{user.id}}' |
| 25 | + target='_blank' role="button">관리</a> |
| 26 | + </div> |
| 27 | + </td> |
| 28 | + </tr> |
| 29 | + {% endfor %} |
| 30 | +</tbody> |
| 31 | +</table> |
| 32 | + |
| 33 | + |
| 34 | +{% endblock %} |
| 35 | + |
| 36 | +{% block head-include %} |
| 37 | +<link href="{% static "components/datatables.net-bs/css/dataTables.bootstrap.min.css" %}" rel="stylesheet"> |
| 38 | +{% endblock %} |
| 39 | + |
| 40 | +{% block script %} |
| 41 | +<script src="{% static "components/datatables.net/js/jquery.dataTables.min.js" %}" charset="utf-8"></script> |
| 42 | +<script src="{% static "components/datatables.net-bs/js/dataTables.bootstrap.min.js" %}" charset="utf-8"></script> |
| 43 | + |
| 44 | +{% verbatim %} |
| 45 | +<script id="print_template" type="text/x-handlebars-template"> |
| 46 | +<div class="ui brother-label"> |
| 47 | + <p class="ui name">{{name}}</p> |
| 48 | +</div> |
| 49 | +<div class="ui brother-label"> |
| 50 | + <p class="ui name">{{topSize}}</p> |
| 51 | +</div> |
| 52 | +<style> |
| 53 | +.brother-label { |
| 54 | + margin: 0 auto; |
| 55 | + padding: 0 auto; |
| 56 | + width: 88mm; |
| 57 | + height: 27mm; |
| 58 | +} |
| 59 | +.name{ |
| 60 | + font-size: {{fontSize}}; |
| 61 | + font-weight: bold; |
| 62 | + text-align: center; |
| 63 | + letter-spacing: 1rem; |
| 64 | +} |
| 65 | +@media print { |
| 66 | + body, html, p{ |
| 67 | + margin: 0mm !important; |
| 68 | + padding: 0mm !important; |
| 69 | + } |
| 70 | + @page{ |
| 71 | + margin: 0mm !important; |
| 72 | + padding: 0mm !important; |
| 73 | + } |
| 74 | +} |
| 75 | +</script> |
| 76 | +{% endverbatim %} |
| 77 | + |
| 78 | +<script type="text/javascript"> |
| 79 | +$(document).ready( function () { |
| 80 | + $('#issue-ticket').DataTable({ |
| 81 | + bInfo: true, |
| 82 | + bLengthChange: true, |
| 83 | + lengthMenu: [[50, 100, 200], [50, 100, 200]], |
| 84 | + order: [[ 0, 'asc' ]], |
| 85 | + paging: true, |
| 86 | + searching: true, |
| 87 | + }); |
| 88 | +}); |
| 89 | + |
| 90 | +function issueTicketConfirm(userId) { |
| 91 | + var csrftoken = Cookies.get('csrftoken'); |
| 92 | + $.ajaxSetup({ |
| 93 | + beforeSend: function(xhr, settings) { |
| 94 | + if (!csrfSafeMethod(settings.type) && !this.crossDomain) { |
| 95 | + xhr.setRequestHeader("X-CSRFToken", csrftoken); |
| 96 | + } |
| 97 | + } |
| 98 | + }); |
| 99 | + $.ajax("{% url 'registration_issue_submit' %}", { |
| 100 | + data: {'user_id': userId}, |
| 101 | + method: 'POST', |
| 102 | + success: function(data) { |
| 103 | + alert('발권처리 기록 되었습니다.'); |
| 104 | + }, |
| 105 | + error: function(data) { |
| 106 | + alert('발권처리 기록에 실패 하였습니다.'); |
| 107 | + } |
| 108 | + }); |
| 109 | +} |
| 110 | + |
| 111 | +function printLabelPopup(name, userId, topSize) { |
| 112 | + var printWindow = window.open('', '', 'width=600, height=400'); |
| 113 | + var fontSize = '1em'; |
| 114 | + var printTemplateScript = $('#print_template').html(); |
| 115 | + var printTemplate = Handlebars.compile(printTemplateScript); |
| 116 | + var context = { |
| 117 | + 'name': name, |
| 118 | + 'topSize': topSize, |
| 119 | + 'fontSize': fontSize |
| 120 | + }; |
| 121 | + printWindow.document.write(printTemplate(context)); |
| 122 | + printWindow.document.close(); |
| 123 | + printWindow.focus(); |
| 124 | + printWindow.print(); |
| 125 | + printWindow.close(); |
| 126 | + issueTicketConfirm(userId); |
| 127 | +} |
| 128 | +</script> |
| 129 | + |
| 130 | +{% endblock %} |
0 commit comments