summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorlevinse <levinse>2011-02-13 07:22:32 +0000
committerlevinse <levinse>2011-02-13 07:22:32 +0000
commite356f2ebb6564fe8d5333fc89bb4583ee3cd1fb1 (patch)
treeac286e1979c4aeecf41ea411fbba20b3aec555e9 /httemplate
parent5226903b423e42e7e8ee135b2b445d362241102a (diff)
bulk DID orders and inventory, RT11291
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/browse/did_order.html65
-rw-r--r--httemplate/browse/did_vendor.html32
-rw-r--r--httemplate/edit/did_order.html46
-rw-r--r--httemplate/edit/did_vendor.html19
-rw-r--r--httemplate/edit/elements/edit.html5
-rw-r--r--httemplate/edit/process/did_order.html21
-rw-r--r--httemplate/edit/process/did_vendor.html11
-rw-r--r--httemplate/elements/menu.html3
-rw-r--r--httemplate/elements/tr-select-state.html19
-rw-r--r--httemplate/misc/phone_avail-import.html32
10 files changed, 249 insertions, 4 deletions
diff --git a/httemplate/browse/did_order.html b/httemplate/browse/did_order.html
new file mode 100644
index 000000000..54c2bd3fc
--- /dev/null
+++ b/httemplate/browse/did_order.html
@@ -0,0 +1,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>
diff --git a/httemplate/browse/did_vendor.html b/httemplate/browse/did_vendor.html
new file mode 100644
index 000000000..04904ec63
--- /dev/null
+++ b/httemplate/browse/did_vendor.html
@@ -0,0 +1,32 @@
+<% include( 'elements/browse.html',
+ 'title' => 'Bulk DID Vendors',
+ 'html_init' => $html_init,
+ 'name' => 'bulk DID vendors',
+ 'disableable' => 0,
+ 'query' => { 'table' => 'did_vendor',
+ 'hashref' => {},
+ 'order_by' => 'ORDER BY vendornum',
+ },
+ 'count_query' => $count_query,
+ 'header' => $header,
+ 'fields' => $fields,
+ 'links' => $links,
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $html_init =
+ qq!<A HREF="${p}edit/did_vendor.html"><I>Add a bulk DID vendor</I></A><BR><BR>!;
+
+my $count_query = 'SELECT COUNT(*) FROM did_vendor';
+
+my $link = [ $p.'edit/did_vendor.html?', 'vendornum' ];
+
+my $header = [ '#', 'Vendor' ];
+my $fields = [ 'vendornum', 'vendorname' ];
+my $links = [ $link, $link ];
+
+</%init>
diff --git a/httemplate/edit/did_order.html b/httemplate/edit/did_order.html
new file mode 100644
index 000000000..ac8f336d4
--- /dev/null
+++ b/httemplate/edit/did_order.html
@@ -0,0 +1,46 @@
+<% include( 'elements/edit.html',
+ 'fields' => [
+ { field => 'vendornum',
+ type => 'select-table',
+ name_col => 'vendorname',
+ table => 'did_vendor',
+ disable_empty => 1,
+ },
+ 'vendor_order_id',
+ 'msa',
+ { field => 'latanum',
+ type => 'select-table',
+ name_col => 'description',
+ table => 'lata',
+ disable_empty => 1,
+ label_showkey => 1,
+ },
+ 'rate_center',
+ { field => 'state',
+ type => 'select-state',
+ country => 'US',
+ },
+ 'quantity',
+ { field => 'confirmed',
+ type => 'input-date-field',
+ },
+ ],
+ 'labels' => {
+ 'vendornum' => 'Vendor',
+ 'vendor_order_id' => 'Vendor Order #',
+ 'msa' => 'MSA',
+ 'latanum' => 'LATA',
+ 'rate_center' => 'Rate Center',
+ },
+ 'viewall_dir' => 'browse',
+ 'table' => 'did_order',
+ 'name' => 'Bulk DID Order',
+ )
+
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Import');
+
+</%init>
diff --git a/httemplate/edit/did_vendor.html b/httemplate/edit/did_vendor.html
new file mode 100644
index 000000000..b6d57b548
--- /dev/null
+++ b/httemplate/edit/did_vendor.html
@@ -0,0 +1,19 @@
+<% include( 'elements/edit.html',
+ 'fields' => [
+ 'vendorname',
+ ],
+ 'labels' => {
+ 'vendorname' => 'Vendor name',
+ },
+ 'viewall_dir' => 'browse',
+ 'table' => 'did_vendor',
+ 'name' => 'Bulk DID Vendor',
+ )
+
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+</%init>
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index cab5167c6..b0c27e62a 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -316,6 +316,11 @@ Example:
% foreach grep exists($f->{$_}),
% qw( formatted_value );
%
+% # select-country
+% $include_common{$_} = $f->{$_}
+% foreach grep exists($f->{$_}),
+% qw( country );
+%
% #htmlarea
% $include_common{$_} = $f->{$_}
% foreach grep exists($f->{$_}), qw( width height );
diff --git a/httemplate/edit/process/did_order.html b/httemplate/edit/process/did_order.html
new file mode 100644
index 000000000..0c9a3f0e0
--- /dev/null
+++ b/httemplate/edit/process/did_order.html
@@ -0,0 +1,21 @@
+<% include( 'elements/process.html',
+ 'table' => 'did_order',
+ 'viewall_dir' => 'browse',
+ 'value_callback' => $value_callback,
+ )
+%>
+<%init>
+
+unless($cgi->param('submitted')) {
+ $cgi->param('submitted',time);
+}
+
+my $value_callback = sub {
+ my ($field, $value) = @_;
+ ($field =~ /ed$/ && $value !~ /^\d+$/) ? parse_datetime($value) : $value;
+};
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Import');
+
+</%init>
diff --git a/httemplate/edit/process/did_vendor.html b/httemplate/edit/process/did_vendor.html
new file mode 100644
index 000000000..891a45392
--- /dev/null
+++ b/httemplate/edit/process/did_vendor.html
@@ -0,0 +1,11 @@
+<% include( 'elements/process.html',
+ 'table' => 'did_vendor',
+ 'viewall_dir' => 'browse',
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+</%init>
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index 710850cc2..651b04d28 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -380,6 +380,8 @@ $tools_menu{'Process payment batches'} = [ $fsurl.'search/pay_batch.cgi?magic=_d
&& $curuser->access_right('Process batches');
$tools_menu{'Download invoice batches'} = [ $fsurl.'search/bill_batch.cgi' ]
if $conf->exists('invoice_print_pdf');
+$tools_menu{'Bulk DID Orders'} = [ $fsurl.'browse/did_order.html', 'View/manage bulk DID orders' ]
+ if $curuser->access_right('Import');
$tools_menu{'Job Queue'} = [ $fsurl.'search/queue.html', 'View pending job queue' ]
if $curuser->access_right('Job queue');
$tools_menu{'Ticketing'} = [ \%tools_ticketing, 'Ticketing tools' ]
@@ -496,6 +498,7 @@ tie my %config_broadband, 'Tie::IxHash',
tie my %config_phone, 'Tie::IxHash',
'View/Edit phone device types' => [ $fsurl.'browse/part_device.html', 'Phone device types' ],
+ 'View/Edit bulk DID vendors' => [ $fsurl.'browse/did_vendor.html', 'Bulk DID vendors' ],
;
tie my %config_misc, 'Tie::IxHash';
diff --git a/httemplate/elements/tr-select-state.html b/httemplate/elements/tr-select-state.html
new file mode 100644
index 000000000..1a62ae561
--- /dev/null
+++ b/httemplate/elements/tr-select-state.html
@@ -0,0 +1,19 @@
+% unless ( $opt{'js_only'} ) {
+ <% include('tr-td-label.html', @_ ) %>
+
+ <TD <% $style %>>
+% }
+
+ <% include( '/elements/select-state.html', %opt ) %>
+
+% unless ( $opt{'js_only'} ) {
+ </TD>
+ </TR>
+% }
+<%init>
+
+my %opt = @_;
+
+my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
+
+</%init>
diff --git a/httemplate/misc/phone_avail-import.html b/httemplate/misc/phone_avail-import.html
index c664c0726..fcbfcc398 100644
--- a/httemplate/misc/phone_avail-import.html
+++ b/httemplate/misc/phone_avail-import.html
@@ -7,7 +7,7 @@ Import a file containing phone numbers (DIDs).
'name' => 'PhonenumImportForm',
'action' => 'process/phone_avail-import.html',
'num_files' => 1,
- 'fields' => [ 'format', 'availbatch', 'exportnum', 'countrycode' ],
+ 'fields' => [ 'format', 'availbatch', 'exportnum', 'countrycode', 'ordernum' ],
'message' => 'DID import successful',
'url' => $p."search/phone_avail.html?availbatch=$availbatch",
)
@@ -15,10 +15,22 @@ Import a file containing phone numbers (DIDs).
<% &ntable("#cccccc", 2) %>
- <INPUT TYPE="hidden" NAME="format" VALUE="default">
<INPUT TYPE="hidden" NAME="availbatch" VALUE="<% $availbatch %>">
+% if ( $ordernum ) {
+ <TR>
+ <TD ALIGN="RIGHT">Bulk DID Order #</TD>
+ <TD><% $ordernum %>
+ <INPUT TYPE="hidden" NAME="ordernum" VALUE="<% $ordernum %>">
+ </TD>
+ </TR>
+% }
+ <TR>
+ <TD ALIGN="RIGHT">Import Format</TD>
+ <TD><% $format %><INPUT TYPE="hidden" NAME="format" VALUE="<% $format %>"></TD>
+ </TR>
+
<% include( '/elements/tr-select-table.html',
'table' => 'part_export',
'name_col' => 'label',
@@ -65,15 +77,18 @@ Import a file containing phone numbers (DIDs).
Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets. The file should have a .CSV or .XLS extension.
<BR><BR>
-<b>Default</b> format has the following field order: <i>state, number, name</i>
+<b>Default</b> format has the following field order: <i>state, number, name</i><br>
+<b>Bulk</b> format has the following field order: <i>state, number, rate center, rate_center_abbrev</i>
<BR><BR>
-
Field information:
<ul>
<li><i>state</i>: Two-letter state code, i.e. "CA"
<li><i>number</i>: Phone number
<li><i>name</i>: optional, rate center
+ <li><i>rate center</i>: rate center (required)
+ <li><i>rate_center_abbrev</i>: rate center abbreviation
</ul>
+<BR><BR>
<% include('/elements/footer.html') %>
@@ -84,6 +99,15 @@ die "access denied"
my $conf = new FS::Conf;
+my $ordernum = $cgi->param('ordernum');
+$ordernum = '' unless $ordernum =~ /^\d+$/;
+
+die 'invalid ordernum'
+ unless (!$ordernum || qsearchs('did_order', { 'ordernum' => $ordernum }));
+
+my $format = 'default';
+$format = 'bulk' if $ordernum;
+
my $availbatch =
time2str('webimport-%Y/%m/%d-%T'. "-$$-". rand() * 2**32, time);