fix new tax report w/FS::tax_rate_location->location_sql, RT#12332
[freeside.git] / httemplate / browse / did_order.html
1 <% include( 'elements/browse.html',
2                  'title'       => 'Bulk DID Orders',
3                  'html_init'   => qq!<A HREF="${p}edit/did_order.html"><I>Add a bulk DID order</I></A><BR><BR>!,
4                  'name'        => 'bulk DID orders',
5                  'disableable' => 0,
6                  'query'       => { 'table'     => 'did_order',
7                                                     'addl_from' => 'left join did_vendor using (vendornum) ',
8                                     'hashref'   => {},
9                                     'order_by' => 'ORDER BY ordernum',
10                                   },
11                  'count_query' => 'SELECT COUNT(*) FROM did_order',
12                  'header'      => [ '#', 'Vendor',' Vendor Order #', 
13                                     'Submitted', 'Confirmed', 'Customer',
14                                     'Received', 'Provision', 'Cancel',
15                                   ],
16                  'fields'      => [ sub {
17                                         my $did_order = shift;
18                                         $did_order->ordernum;
19                                     }, 
20                                     'vendorname', 
21                                     'vendor_order_id', 
22                                     sub { &$display_date(shift->submitted); },
23                                     sub {
24                                         my $did_order = shift;
25                                         my $ordernum = $did_order->ordernum;
26                                         return &$display_date($did_order->confirmed) 
27                                             if $did_order->confirmed;
28                                         include( '/elements/popup_link.html',
29                                           { 'action'      => "${p}misc/did_order_confirm.html?ordernum=$ordernum",
30                                             'label'       => 'Confirm',
31                                             'actionlabel' => 'Confirm Bulk DID Order',
32                                             'width'       => 480,
33                                             'height'      => 300,
34                                           }
35                                         )
36                                     }, 
37                                     sub {
38                                         my $did_order = shift;
39                                         my $cust_main = $did_order->cust_main;
40                                         return "Stock" unless $cust_main;
41                                         "<A HREF='${p}view/cust_main.cgi?".$cust_main->custnum."'>".$cust_main->name."</A>";
42                                     },
43                                     sub { 
44                                         my $did_order = shift;
45                                         my $ordernum = $did_order->ordernum;
46                                         return &$display_date($did_order->received) 
47                                             if $did_order->received;
48                                         "<A HREF='${p}misc/phone_avail-import.html?ordernum=$ordernum'>Upload Received</A>";
49                                     },
50                                     sub {
51                                         my $did_order = shift;
52                                         my $ordernum = $did_order->ordernum;
53                                         my @provisioned = 
54                                             qsearch({ table   => 'phone_avail',
55                                                       hashref => { 'ordernum' => $ordernum, },
56                                                       select  => 'phone_avail.*',
57                                                       extra_sql => ' and svcnum is not null ',
58                                                     });
59                                         return '' 
60                                             unless $did_order->received 
61                                                         && $did_order->custnum
62                                                         && !scalar(@provisioned);
63                                         include( '/elements/popup_link.html',
64                                           { 'action'      => "${p}misc/did_order_provision.html?ordernum=".$did_order->ordernum,
65                                             'label'       => 'Provision All DIDs',
66                                             'actionlabel' => 'Bulk DID order - DID provisioning',
67                                             'width'       => 520,
68                                             'height'      => 300,
69                                           }
70                                         )
71                                     },
72                                     sub {
73                                         my $did_order = shift;
74                                         return '' unless !$did_order->received;
75                                         qq!<A HREF="javascript:areyousure('${p}misc/did_order_confirmed.html?action=cancel;ordernum=!
76                                         . $did_order->ordernum . qq!', 'Cancel this order (#!
77                                         . $did_order->ordernum . qq!)?')">Cancel</A>!
78                                     },
79                                   ],
80                  'links'       => [
81                                     [ $p.'edit/did_order.html?', 'ordernum' ],
82                                                   ],
83                  'html_foot' => '
84                             <script type="text/javascript">
85                                 function areyousure(href,msg) {
86                                     if (confirm(msg))
87                                         window.location.href = href;
88                                 }
89                             </script>
90                                 ',
91              )
92 %>
93 <%init>
94
95 die "access denied"
96   unless $FS::CurrentUser::CurrentUser->access_right('Import');
97
98 my $conf = new FS::Conf;
99 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
100
101 my $display_date = sub {
102     my $date = shift;
103     return '' unless $date;
104     time2str($date_format, $date);
105 };
106
107 </%init>