diff options
Diffstat (limited to 'httemplate/elements/contact.html')
-rw-r--r-- | httemplate/elements/contact.html | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/httemplate/elements/contact.html b/httemplate/elements/contact.html new file mode 100644 index 000000000..a7a33b1f0 --- /dev/null +++ b/httemplate/elements/contact.html @@ -0,0 +1,56 @@ +% unless ( $opt{'js_only'} ) { + + <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>"> + + <TABLE> + <TR> +% foreach my $field ( @fields ) { + <TD> + <INPUT TYPE = "text" + NAME = "<%$name%>_<%$field%>" + ID = "<%$id%>_<%$field%>" + VALUE = "<% scalar($cgi->param($name."_$field")) + || $contact->get($field) |h %>" + <% $onchange %> + ><BR> + <FONT SIZE="-1"><% $label{$field} %></FONT> + </TD> +% } + </TR> + </TABLE> + +% } +<%init> + +my( %opt ) = @_; + +my $name = $opt{'element_name'} || $opt{'field'} || 'contactnum'; +my $id = $opt{'id'} || 'contactnum'; + +my $curr_value = $opt{'curr_value'} || $opt{'value'}; + +my $onchange = ''; +if ( $opt{'onchange'} ) { + $onchange = $opt{'onchange'}; + $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/; + $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange + #callbacks should act the same + $onchange = 'onChange="'. $onchange. '"'; +} + +my $contact; +if ( $curr_value ) { + $contact = qsearchs('contact', { 'contactnum' => $curr_value } ); +} else { + $contact = new FS::contact {}; +} + +tie my %label, 'Tie::IxHash', + 'first' => 'First name', + 'last' => 'Last name', + 'title' => 'Title/Position', + 'comment' => 'Comment', +; +my @fields = keys %label; + +</%init> |