summaryrefslogtreecommitdiff
path: root/httemplate/browse/did_order.html
blob: 54c2bd3fc6d9fa64fa9180c4ff71a9cb4f001f48 (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
<% include( 'elements/browse.html',
                 'title'       => 'Bulk DID Orders',
                 'html_init'   => $html_init,
                 'name'        => 'bulk DID orders',
                 'disableable' => 0,
                 'query'       => { 'table'     => 'did_order',
				    'addl_from' => 'left join did_vendor using (vendornum) 
						    left join lata using (latanum)',
                                    'hashref'   => {},
                                    'order_by' => 'ORDER BY ordernum',
                                  },
                 'count_query' => $count_query,
                 'header'      => $header,
                 'fields'      => $fields,
                 'links'       => $links,
             )
%>
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Import');

my $conf = new FS::Conf;
my $date_format = $conf->config('date_format') || '%m/%d/%Y';

my $html_init = 
  qq!<A HREF="${p}edit/did_order.html"><I>Add a bulk DID order</I></A><BR><BR>!;

my $count_query = 'SELECT COUNT(*) FROM did_order';

my $link = [ $p.'edit/did_order.html?', 'ordernum' ];

my $display_date = sub {
    my $date = shift;
    return '' unless $date;
    time2str($date_format, $date);
};

my $header = [ '#', 'Vendor',' Vendor Order #', 'MSA', 'LATA #', 'LATA', 
		'Rate Center', 'State', 'Quantity', 'Submitted', 'Confirmed',
		'Received', 
	    ];
my $links  = [ ];
my $fields = [  sub {
		    my $did_order = shift;
		    if($did_order->received) {
			push @$links, $link;
		    }
		    else {
			return $did_order->ordernum;
		    }
		}, 'vendorname', 'vendor_order_id', 'msa', 'latanum',
		'description', 'rate_center', 'state', 'quantity', 
		sub { &$display_date(shift->submitted); }, 
		sub { &$display_date(shift->confirmed);	}, 
		sub { 
		    my $did_order = shift;
		    my $ordernum = $did_order->ordernum;
		    return &$display_date($did_order->received) 
			if $did_order->received;
		    "<A HREF='${p}misc/phone_avail-import.html?ordernum=$ordernum'>Upload Received</A>";
		}, 
	     ];

</%init>