Lines 2-21
Link Here
|
2 |
[% BLOCK edit_contact %] |
2 |
[% BLOCK edit_contact %] |
3 |
<ol id="contact-form"> |
3 |
<ol id="contact-form"> |
4 |
<input type="hidden" name="contact_id" value="[% contact.id %]" /> |
4 |
<input type="hidden" name="contact_id" value="[% contact.id %]" /> |
5 |
<li><label for="contact_name">Contact name: </label> |
5 |
<li><label for="contact_name[% contact.id %]">Contact name: </label> |
6 |
<input type="text" size="40" id="contact_name" name="contact_name" value="[% contact.name %]" /></li> |
6 |
<input type="text" size="40" id="contact_name[% contact.id %]" name="contact_name" value="[% contact.name %]" /></li> |
7 |
<li><label for="contact_position">Position: </label> |
7 |
<li><label for="contact_position[% contact.id %]">Position: </label> |
8 |
<input type="text" size="40" id="contact_position" name="contact_position" value="[% contact.position %]" /></li> |
8 |
<input type="text" size="40" id="contact_position[% contact.id %]" name="contact_position" value="[% contact.position %]" /></li> |
9 |
<li><label for="contact_phone">Phone: </label> |
9 |
<li><label for="contact_phone[% contact.id %]">Phone: </label> |
10 |
<input type="text" size="20" id="contact_phone" name="contact_phone" value="[% contact.phone %]" /> </li> |
10 |
<input type="text" size="20" id="contact_phone[% contact.id %]" name="contact_phone" value="[% contact.phone %]" /> </li> |
11 |
<li><label for="contact_phone_2">Alternative phone: </label> |
11 |
<li><label for="contact_altphone[% contact.id %]">Alternative phone: </label> |
12 |
<input type="text" size="20" id="contact_altphone" name="contact_altphone" value="[% contact.altphone %]" /></li> |
12 |
<input type="text" size="20" id="contact_altphone[% contact.id %]" name="contact_altphone" value="[% contact.altphone %]" /></li> |
13 |
<li><label for="contact_fax">Fax: </label> |
13 |
<li><label for="contact_fax[% contact.id %]">Fax: </label> |
14 |
<input type="text" size="20" id="contact_fax" name="contact_fax" value="[% contact.fax %]" /></li> |
14 |
<input type="text" size="20" id="contact_fax[% contact.id %]" name="contact_fax" value="[% contact.fax %]" /></li> |
15 |
<li><label for="contact_email">Email: </label> |
15 |
<li><label for="contact_email[% contact.id %]">Email: </label> |
16 |
<input type="text" size="40" id="contact_email" name="contact_email" value="[% contact.email %]" /></li> |
16 |
<input type="text" size="40" id="contact_email[% contact.id %]" name="contact_email" value="[% contact.email %]" /></li> |
17 |
<li><label for="contact_notes">Notes: </label> |
17 |
<li><label for="contact_notes[% contact.id %]">Notes: </label> |
18 |
<textarea id="contact_notes" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li> |
18 |
<textarea id="contact_notes[% contact.id %]" name="contact_notes" cols="40" rows="4">[% contnotes %]</textarea></li> |
|
|
19 |
[% IF contact.id %]<li><button class="btn" class="delete-contact"><i class="icon-remove"></i>Delete contact</li>[% END %] |
19 |
</ol> |
20 |
</ol> |
20 |
[% END %] |
21 |
[% END %] |
21 |
[% BLOCK show_contact %] |
22 |
[% BLOCK show_contact %] |
Lines 46-51
function confirm_deletion() {
Link Here
|
46 |
} |
47 |
} |
47 |
|
48 |
|
48 |
function add_contact() { |
49 |
function add_contact() { |
|
|
50 |
var new_contact = $('#contact-template').clone(); |
51 |
var timestamp = new Date().getTime(); |
52 |
$(new_contact).removeAttr('id'); |
53 |
$('input, textarea', new_contact).each(function () { |
54 |
$(this).attr('id', $(this).attr('id') + '_' + timestamp); |
55 |
}); |
56 |
$('label', new_contact).each(function () { |
57 |
$(this).attr('for', $(this).attr('for') + '_' + timestamp); |
58 |
}); |
59 |
$(new_contact).insertBefore(this); |
60 |
$('input[name="contact_name"]', new_contact).focus(); |
61 |
return false; |
62 |
} |
63 |
|
64 |
function delete_contact() { |
65 |
$(this).parents('fieldset').delete(); |
66 |
return false; |
49 |
} |
67 |
} |
50 |
|
68 |
|
51 |
$(document).ready(function() { |
69 |
$(document).ready(function() { |
Lines 56-61
function add_contact() {
Link Here
|
56 |
], |
74 |
], |
57 |
'sDom': 't' |
75 |
'sDom': 't' |
58 |
} ) ); |
76 |
} ) ); |
|
|
77 |
$('.delete-contact').click(delete_contact); |
78 |
$('#add-contact').click(add_contact); |
59 |
}); |
79 |
}); |
60 |
//]]> |
80 |
//]]> |
61 |
</script> |
81 |
</script> |
Lines 100-111
function add_contact() {
Link Here
|
100 |
<li><label for="accountnumber">Account number: </label> |
120 |
<li><label for="accountnumber">Account number: </label> |
101 |
<input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol> |
121 |
<input type="text" size="40" id="accountnumber" name="accountnumber" value="[% accountnumber %]" /></li></ol> |
102 |
</fieldset> |
122 |
</fieldset> |
103 |
[% FOREACH contact IN contacts %] |
123 |
<fieldset class="rows"> |
104 |
<fieldset class="supplier-contact rows"> |
124 |
<legend>Contacts</legend> |
|
|
125 |
<fieldset id="contact-template" class="supplier-contact"> |
105 |
<legend>Contact details</legend> |
126 |
<legend>Contact details</legend> |
106 |
[% INCLUDE edit_contact %] |
127 |
[% INCLUDE edit_contact %] |
107 |
</fieldset> |
128 |
</fieldset> |
108 |
[% END %] |
129 |
[% FOREACH contact IN contacts %] |
|
|
130 |
<fieldset class="supplier-contact"> |
131 |
<legend>Contact details</legend> |
132 |
[% INCLUDE edit_contact %] |
133 |
</fieldset> |
134 |
[% END %] |
135 |
<button id="add-contact" class="btn"><i class="icon-plus"></i>Add contact</button> |
136 |
</fieldset> |
109 |
</div> |
137 |
</div> |
110 |
<div class="yui-g"> |
138 |
<div class="yui-g"> |
111 |
<fieldset class="rows"> |
139 |
<fieldset class="rows"> |