summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-cust_phone.html
blob: 94cd41322f906dad1c5385e247268826d217567e (plain)
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
<SELECT NAME="<% $opt{'field_name'} %>" ID="<% $opt{'field_name'} %>">

     <OPTION VALUE="" selected="selected">Select a phone number

% foreach $p (@$phone_types) {
	<OPTION VALUE="<% $phones_formatted{$p} %>"><% $p |h%> (<% $cust_phones->$p |h %>)		
%}

</SELECT>

<%init>

my %opt = @_;
my $cust_num     = $opt{'cust_num'};
my $phone_types  = $opt{'phone_types'};
my $format 	  = $opt{'format'};

my $cust_phones = qsearchs('cust_main', { 'custnum' => $cust_num })
  or die 'unknown custnum' . $cust_num;

my %phones_formatted = map {
	$_ => format_phone_number($cust_phones->$_, $format)
} @$phone_types;

sub format_phone_number {
	my ($n, $f) = @_;
	if ($f eq 'xxxxxxxxxx') { $n =~ s/-//g; }	
	return $n;
}

</%init>