summaryrefslogtreecommitdiff
path: root/httemplate/elements/tr-select-sales.html
blob: f77ef50b776e17dda9d74fdc12eb81436d5d9c09 (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
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
<%doc>

Example:

  <& /elements/tr-select-sales.html',

    #recommended to keep things "sticky" on errors
    'curr_value'    => $curr_value,

    ##
    # optional
    ##

    'label'         => 'Sales Person',
    'empty_label'   => 'Select sales person', #override default 
    #on already# 'disable_empty' => 1,

  &>

</%doc>
% if ( scalar(@sales) == 0 || $opt{'fixed'} ) { 

  <INPUT TYPE  = "hidden"
         NAME  = "<% $opt{'field'} || 'salesnum' %>"
         ID    = "<% $opt{'field'} || 'salesnum' %>"
         VALUE = "<% $salesnum %>"
  >

%   if ( scalar(@sales) > 0 ) {
      <TR>
        <TD ALIGN="right"><% $opt{'label'} || emt('Sales Person') %></TD>
        <TD BGCOLOR="#dddddd" <% $colspan %>>
%         my $sales = qsearchs('sales', { 'salesnum' => $salesnum });
          <% $sales ? $sales->salesperson : '(none)' |h %>
        </TD>
      </TR>

%   } else { # YUCK.  empty row so we don't throw g_row in edit.html off :/
      <TR>
      </TR>
%   }
%
% } else { 

  <TR>
    <TD ALIGN="right"><% $opt{'label'} || emt('Sales Person') %></TD>
    <TD <% $colspan %>>
      <& /elements/select-sales.html,
                     'curr_value' => $salesnum,
                     'sales'     => \@sales,
                     %opt,
      &>
    </TD>
  </TR>

% } 

<%init>

my $curuser = $FS::CurrentUser::CurrentUser;

my %opt = @_;
my $salesnum = $opt{'curr_value'} || $opt{'value'};

my @sales = qsearch({ 'table'   => 'sales',
                      'hashref' => { 'disabled' => '' },
                      'extra_sql' => ' AND '. $curuser->agentnums_sql,
                   });
warn scalar(@sales);
my $colspan = $opt{'colspan'} ? 'COLSPAN="'.$opt{'colspan'}.'"' : '';

</%init>