summaryrefslogtreecommitdiff
path: root/httemplate/browse/did_order.html
blob: 570b78475d16d5f2c07401980ecc0583cb0c7e43 (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
73
<% 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) ',
                                    'hashref'   => {},
                                    'order_by' => 'ORDER BY ordernum',
                                  },
                 'count_query' => $count_query,
                 'header'      => $header,
                 'fields'      => $fields,
                 'links'       => [
				    [ $p.'edit/did_order.html?', 'ordernum' ],
				  ],
             )
%>
<%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 $display_date = sub {
    my $date = shift;
    return '' unless $date;
    time2str($date_format, $date);
};

my $header = [ '#', 'Vendor',' Vendor Order #', 'Submitted', 'Confirmed',
                'Customer', 'Received', ];
my $fields = [  sub {
		    my $did_order = shift;
		    $did_order->ordernum;
		}, 'vendorname', 'vendor_order_id', 
		sub { &$display_date(shift->submitted); }, 
		sub {
		    my $did_order = shift;
		    my $ordernum = $did_order->ordernum;
            return &$display_date($did_order->confirmed) if $did_order->confirmed;
            include( '/elements/popup_link.html',
              { 'action'      => "${p}misc/did_order_confirm.html?ordernum=$ordernum",
                'label'       => 'Confirm&nbsp;Bulk&nbsp;DID&nbsp;Order',
                'actionlabel' => 'Confirm Bulk DID Order',
                'width'       => 480,
                'height'      => 300,
              }
            )
        }, 
        sub {
            my $did_order = shift;
            my $cust_main = $did_order->cust_main;
            return "Stock" unless $cust_main;
            "<A HREF='${p}view/cust_main.cgi?".$cust_main->custnum."'>".$cust_main->name."</A>";
        },
		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>