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
<h3><i class="icon-paste"></i> Manage Forms</i></h3>
<b><a class="close" href="#"><i class="icon-remove-circle"></i></a></b>
<hr/>
Sort the forms on this ticket by click and dragging on them. Use the box
below the forms list to add new forms to the ticket.
<br/>
<br/>
<form method="post" action="#tickets/<?php echo $ticket_id; ?>/forms/manage">
<div id="ticket-entries">
<?php
$current_list = array();
foreach (DynamicFormEntry::forTicket($ticket_id) as $e) { ?>
<div class="sortable-row-item" data-id="<?php echo $e->get('id'); ?>">
<input type="hidden" name="forms[]" value="<?php echo $e->get('form_id'); ?>" />
<i class="icon-reorder"></i> <?php echo $e->getForm()->getTitle();
$current_list[] = $e->get('form_id');
if ($e->getForm()->get('type') == 'G') { ?>
<div class="delete"><a href="#"><i class="icon-trash"></i></a></div>
<?php } ?>
</div>
<?php } ?>
</div>
<hr/>
<i class="icon-plus"></i>
<select name="new-form" onchange="javascript:
var $sel = $(this).find('option:selected');
$('#ticket-entries').append($('<div></div>').addClass('sortable-row-item')
.text(' '+$sel.text())
.data('id', $sel.val())
.prepend($('<i>').addClass('icon-reorder'))
.append($('<input/>').attr({name:'forms[]', type:'hidden'}).val($sel.val()))
.append($('<div></div>').addClass('delete')
.append($('<a href=\'#\'>').append($('<i>').addClass('icon-trash')))
)
);
$sel.prop('disabled',true);">
<option selected="selected" disabled="disabled">Add a new form to this ticket</option>
<?php foreach (DynamicForm::objects()->filter(array(
'type'=>'G')) as $f
) {
if (in_array($f->get('id'), $current_list))
continue;
?><option value="<?php echo $f->get('id'); ?>"><?php
echo $f->getTitle(); ?></option><?php
} ?>
</select>
<div id="delete-warning" style="display:none">
<hr>
<div id="msg_warning">
Clicking <strong>Save Changes</strong> will permanently delete data
associated with the deleted forms
</div>
</div>
<hr>
<p class="full-width">
<span class="buttons" style="float:left">
<input type="reset" value="Reset">
<input type="button" name="cancel" class="<?php echo $user ? 'cancel' : 'close' ?>" value="Cancel">
</span>
<span class="buttons" style="float:right">
<input type="submit" value="Save Changes">
</span>
</p>
<script type="text/javascript">
$(function() {
$('#ticket-entries').sortable({containment:'parent',tolerance:'pointer'});
$('#ticket-entries .delete a').live('click', function() {
var $div = $(this).closest('.sortable-row-item');
$('select[name=new-form]').find('option[data-id='+$div.data('id')+']')
.prop('disabled',false);
$div.remove();
$('#delete-warning').show();
return false;
})
});
</script>