summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevinse <levinse>2011-04-11 23:03:33 +0000
committerlevinse <levinse>2011-04-11 23:03:33 +0000
commita75c66ffe670d078f27032f653ead9cfe6ceacd5 (patch)
tree4df40a929270889ad4c35dd7772570e2fbb66474
parentacc396cf5f6274b43567d49c9351a9c32bff9cfb (diff)
improvements to bulk DID orders, RT11291
-rw-r--r--FS/FS/Schema.pm2
-rw-r--r--FS/FS/did_order.pm11
-rw-r--r--httemplate/browse/did_order.html28
-rw-r--r--httemplate/edit/did_order.html94
-rw-r--r--httemplate/edit/process/did_order.html18
-rw-r--r--httemplate/elements/did_order_item.html46
-rw-r--r--httemplate/misc/did_order_confirm.html42
-rw-r--r--httemplate/misc/did_order_confirmed.html37
8 files changed, 210 insertions, 68 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index f48e8f9ea..8f8b5ec69 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -2890,7 +2890,7 @@ sub tables_hashref {
'msa', 'varchar', 'NULL', $char_d, '', '',
'npa', 'int', 'NULL', '', '', '',
'latanum', 'int', 'NULL', '', '', '',
- 'rate_center', 'varchar', 'NULL', $char_d, '', '',
+ 'ratecenter', 'varchar', 'NULL', $char_d, '', '',
'state', 'char', 'NULL', 2, '', '',
'quantity', 'int', '', '', '', '',
],
diff --git a/FS/FS/did_order.pm b/FS/FS/did_order.pm
index f46d72bf8..adc965f91 100644
--- a/FS/FS/did_order.pm
+++ b/FS/FS/did_order.pm
@@ -138,6 +138,17 @@ sub did_order_item {
qsearch( 'did_order_item', { 'ordernum' => $self->ordernum } );
}
+=item cust_main
+
+Returns the cust_main (see L<FS::cust_main>), if any, associated with this bulk DID order.
+
+=cut
+
+sub cust_main {
+ my $self = shift;
+ return '' unless $self->custnum;
+ qsearchs('cust_main', { 'custnum' => $self->custnum } );
+}
=back
diff --git a/httemplate/browse/did_order.html b/httemplate/browse/did_order.html
index e844169b3..570b78475 100644
--- a/httemplate/browse/did_order.html
+++ b/httemplate/browse/did_order.html
@@ -35,21 +35,37 @@ my $display_date = sub {
time2str($date_format, $date);
};
-my $header = [ '#', 'Vendor',' Vendor Order #',
- 'Submitted', 'Confirmed', 'Customer', 'Received',
- ];
+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 { &$display_date(shift->confirmed); },
- 'custnum',
+ 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;
+ if $did_order->received;
"<A HREF='${p}misc/phone_avail-import.html?ordernum=$ordernum'>Upload Received</A>";
},
];
diff --git a/httemplate/edit/did_order.html b/httemplate/edit/did_order.html
index 25e38c72e..f20e34708 100644
--- a/httemplate/edit/did_order.html
+++ b/httemplate/edit/did_order.html
@@ -7,69 +7,57 @@
disable_empty => 1,
},
{ field => 'vendor_order_id',
- type => 'hidden',
- },
+ type => 'hidden',
+ },
{ field => 'confirmed',
type => 'hidden',
},
- 'custnum',
- { type => 'tablebreak-tr-title',
- value => 'Order Items',
- },
- { 'field' => 'orderitemnum',
- 'type' => 'did_order_item',
- 'o2m_table' => 'did_order_item',
- 'm2_label' => 'Item',
- 'm2_error_callback' => $m2_error_callback,
- },
- #'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 => 'stock_or_customer',
+ type => 'radio',
+ options => [ 'Stock', 'Customer', ],
+ onchange => 'stockcust_changed',
+ curr_value_callback => $stock_or_customer,
+ },
+ { field => 'custnum',
+ type => 'search-cust_main',
+ },
+ { type => 'tablebreak-tr-title',
+ value => 'Order Items',
+ },
+ { 'field' => 'orderitemnum',
+ 'type' => 'did_order_item',
+ 'o2m_table' => 'did_order_item',
+ 'm2_label' => 'Item',
+ 'm2_error_callback' => $m2_error_callback,
+ },
+ ],
'labels' => {
'ordernum' => 'Order',
'vendornum' => 'Vendor',
'vendor_order_id' => 'Vendor Order #',
- 'custnum' => 'Customer',
- #'msa' => 'MSA',
- #'latanum' => 'LATA',
- #'rate_center' => 'Rate Center',
- #'state' => 'State',
- #'quantity' => 'Quantity',
+ 'custnum' => '',
'confirmed' => 'Confirmation Date',
- 'orderitemnum' => 'Item',
+ 'orderitemnum' => 'Item',
},
'viewall_dir' => 'browse',
'table' => 'did_order',
'name' => 'Bulk DID Order',
- 'field_callback' => $field_callback,
+ 'field_callback' => $field_callback,
+ 'html_bottom' => $javascript,
)
-
%>
<%init>
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Import');
-
my $field_callback = sub {
my ($cgi, $object, $field_hashref ) = @_;
if ($object->ordernum) {
$field_hashref->{type} = 'text'
- if $field_hashref->{field} eq 'vendor_order_id';
+ if $field_hashref->{field} eq 'vendor_order_id';
$field_hashref->{type} = 'input-date-field'
- if $field_hashref->{field} eq 'confirmed';
+ if $field_hashref->{field} eq 'confirmed';
}
};
@@ -77,7 +65,7 @@ my $m2_error_callback = sub {
my($cgi, $object) = @_;
#process_o2m fields in process/did_order.html
- my @fields = qw( msa npa latanum rate_center state quantity );
+ my @fields = qw( msa npa latanum ratecenter state quantity );
my @gfields = ( '', map "_$_", @fields );
map {
@@ -99,5 +87,31 @@ my $m2_error_callback = sub {
$cgi->param;
};
+my $stock_or_customer = sub{
+ my($cgi,$object,$field) = @_;
+ return 'Customer' if $object->custnum;
+ 'Stock';
+};
+
+my $javascript = <<END;
+ <SCRIPT TYPE="text/javascript">
+ function stockcust_changed() {
+ var f = document.edit_topform;
+ var custnum = f.custnum;
+ var custnum_search = f.custnum_search;
+ var custnum_select = f.custnum_select;
+ if ( f.stock_or_customer_Stock.checked ) {
+ custnum_search.disabled = true;
+ custnum_select.disabled = true;
+ }
+ else if ( f.stock_or_customer_Customer.checked ) {
+ custnum_search.disabled = false;
+ custnum_select.disabled = false;
+ }
+ custnum.value = '';
+ custnum_search.value = '';
+ }
+ </SCRIPT>
+END
</%init>
diff --git a/httemplate/edit/process/did_order.html b/httemplate/edit/process/did_order.html
index e5948ff0b..1762cfa25 100644
--- a/httemplate/edit/process/did_order.html
+++ b/httemplate/edit/process/did_order.html
@@ -1,15 +1,18 @@
<% include( 'elements/process.html',
'table' => 'did_order',
'viewall_dir' => 'browse',
- 'value_callback' => $value_callback,
- 'process_o2m' => {
- 'table' => 'did_order_item',
- 'fields' => \@item_fields,
- },
+ 'value_callback' => $value_callback,
+ 'process_o2m' => {
+ 'table' => 'did_order_item',
+ 'fields' => \@item_fields,
+ },
)
%>
<%init>
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Import');
+
unless($cgi->param('submitted')) {
$cgi->param('submitted',time);
}
@@ -19,9 +22,6 @@ my $value_callback = sub {
($field =~ /ed$/ && $value !~ /^\d+$/) ? parse_datetime($value) : $value;
};
-my @item_fields = qw( msa npa latanum rate_center state quantity );
-
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Import');
+my @item_fields = qw( msa npa latanum ratecenter state quantity );
</%init>
diff --git a/httemplate/elements/did_order_item.html b/httemplate/elements/did_order_item.html
index 263826ecc..0f5a76516 100644
--- a/httemplate/elements/did_order_item.html
+++ b/httemplate/elements/did_order_item.html
@@ -4,7 +4,7 @@
<TABLE>
<TR>
-% foreach my $field ( @fields ) {
+% foreach my $field ( @textfields ) {
%
% my $value = '';
% $value = $item->get($field);
@@ -17,10 +17,37 @@
VALUE = "<% scalar($cgi->param($name."_$field"))
|| $value |h %>"
<% $onchange %>
- ><BR>
- <FONT SIZE="-1"><% $label{$field} %></FONT>
+ >
+ <BR><FONT SIZE="-1"><% $label{$field} %></FONT>
</TD>
% }
+% my $value = '';
+% $value = $item->get('latanum');
+ <TD><% include('/elements/select-table.html',
+ 'name_col' => 'description',
+ 'table' => 'lata',
+ 'disable_empty' => 0,
+ 'empty_label' => ' ',
+ 'label_showkey' => 1,
+ 'field' => "${name}_latanum",
+ 'curr_value' => scalar($cgi->param("${name}_latanum"))
+ || $value,
+ )
+ %>
+ <BR><FONT SIZE="-1">LATA #</FONT>
+ </TD>
+% $value = $item->get('state');
+ <TD><% include('/elements/select-state.html',
+ 'disable_empty' => 0,
+ 'empty_label' => ' ',
+ 'country' => 'US',
+ 'prefix' => "${name}_",
+ 'state' => scalar($cgi->param("${name}_state"))
+ || $value,
+ )
+ %>
+ <BR><FONT SIZE="-1">State</FONT>
+ </TD>
</TR>
</TABLE>
@@ -51,19 +78,14 @@ if ( $curr_value ) {
}
my %size = ( 'npa' => 3,
- 'latanum' => 3,
- 'state' => 2,
'quantity' => 3,);
tie my %label, 'Tie::IxHash',
- 'msa' => 'MSA',
- 'npa' => 'NPA',
- 'latanum' => 'LATA #',
- 'rate_center' => 'Rate Center',
- 'state' => 'State',
'quantity' => 'Quantity',
+ 'npa' => 'NPA',
+ 'ratecenter' => 'Rate Center',
+ 'msa' => 'MSA',
;
-
-my @fields = keys %label;
+my @textfields = keys %label;
</%init>
diff --git a/httemplate/misc/did_order_confirm.html b/httemplate/misc/did_order_confirm.html
new file mode 100644
index 000000000..40495a5e9
--- /dev/null
+++ b/httemplate/misc/did_order_confirm.html
@@ -0,0 +1,42 @@
+<% include('/elements/header-popup.html', 'Confirm Bulk DID Order' ) %>
+
+<% include('/elements/error.html') %>
+
+<FORM NAME="did_order_confirm" ACTION="<% popurl(1) %>did_order_confirmed.html" METHOD=POST>
+<INPUT TYPE="hidden" NAME="ordernum" VALUE="<% $ordernum %>">
+<TABLE>
+ <TR>
+ <TD>Order #</TD>
+ <TD><% $ordernum %></TD>
+ </TR>
+ <% include( '/elements/tr-input-text.html',
+ 'field' => 'vendor_order_id',
+ 'label' => 'Vendor Order #',
+ 'value' => $did_order->vendor_order_id,
+ )
+ %>
+ <% include( '/elements/tr-input-date-field.html', {
+ 'name' => 'confirmed',
+ 'label' => 'Order Confirmed',
+ 'value' => $did_order->confirmed,
+ })
+ %>
+ <TR>
+ <TD COLSPAN="2"><INPUT TYPE="SUBMIT" value="Confirm"></TD>
+ </TR>
+</TABLE>
+
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Import');
+
+$cgi->param('ordernum') =~ /^(\d+)$/ or die 'illegal ordernum';
+my $ordernum = $1;
+my $did_order = qsearchs( {
+ 'table' => 'did_order',
+ 'hashref' => { 'ordernum' => $ordernum },
+} );
+die "No order $ordernum" unless $did_order;
+
+</%init>
diff --git a/httemplate/misc/did_order_confirmed.html b/httemplate/misc/did_order_confirmed.html
new file mode 100644
index 000000000..53a41a738
--- /dev/null
+++ b/httemplate/misc/did_order_confirmed.html
@@ -0,0 +1,37 @@
+<% include('/elements/header-popup.html', "DID order confirmed") %>
+ <SCRIPT TYPE="text/javascript">
+ window.top.location.reload();
+ </SCRIPT>
+ </BODY>
+</HTML>
+<%init>
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Import');
+
+$cgi->param('ordernum') =~ /^(\d+)$/ or die 'illegal ordernum';
+my $ordernum = $1;
+my $did_order = qsearchs( {
+ 'table' => 'did_order',
+ 'hashref' => { 'ordernum' => $ordernum },
+} );
+die "No order $ordernum" unless $did_order;
+
+my $confirmed = '';
+$confirmed = parse_datetime($cgi->param('confirmed'))
+ if $cgi->param('confirmed') && $cgi->param('confirmed') !~ /^\d+$/;
+$confirmed = $1
+ if $cgi->param('confirmed') && $cgi->param('confirmed') =~ /^(\d+)$/;
+
+die "invalid confirmation date" unless $confirmed;
+
+my $error = '';
+$did_order->confirmed($confirmed);
+$did_order->vendor_order_id($cgi->param('vendor_order_id'));
+$error = $did_order->replace;
+
+if ( $error ) {
+ $cgi->param('error', $error);
+ print $cgi->redirect(popurl(1). "did_order_confirm.html?". $cgi->query_string );
+}
+
+</%init>