summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorlevinse <levinse>2011-04-15 03:04:13 +0000
committerlevinse <levinse>2011-04-15 03:04:13 +0000
commit59be9ba7caf1009a97af97156bbd700bffb18fd4 (patch)
treec58f49cb73e529ec8ee77200918f2ca412f849ee /httemplate
parentf2cefba60adbf732299acda09d52024748665eef (diff)
FS/FS/msa.pm
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/browse/did_order.html128
-rw-r--r--httemplate/edit/did_order.html18
-rw-r--r--httemplate/edit/process/did_order.html15
-rw-r--r--httemplate/elements/did_order_item.html100
-rw-r--r--httemplate/misc/did_order_confirm.html1
-rw-r--r--httemplate/misc/did_order_confirmed.html45
-rw-r--r--httemplate/misc/did_order_provision.html35
7 files changed, 239 insertions, 103 deletions
diff --git a/httemplate/browse/did_order.html b/httemplate/browse/did_order.html
index 570b78475..363a20108 100644
--- a/httemplate/browse/did_order.html
+++ b/httemplate/browse/did_order.html
@@ -1,19 +1,93 @@
<% include( 'elements/browse.html',
'title' => 'Bulk DID Orders',
- 'html_init' => $html_init,
+ 'html_init' => qq!<A HREF="${p}edit/did_order.html"><I>Add a bulk DID order</I></A><BR><BR>!,
'name' => 'bulk DID orders',
'disableable' => 0,
'query' => { 'table' => 'did_order',
- 'addl_from' => 'left join did_vendor using (vendornum) ',
+ 'addl_from' => 'left join did_vendor using (vendornum) ',
'hashref' => {},
'order_by' => 'ORDER BY ordernum',
},
- 'count_query' => $count_query,
- 'header' => $header,
- 'fields' => $fields,
+ 'count_query' => 'SELECT COUNT(*) FROM did_order',
+ 'header' => [ '#', 'Vendor',' Vendor Order #',
+ 'Submitted', 'Confirmed', 'Customer',
+ 'Received', 'Provision', 'Cancel',
+ ],
+ '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',
+ '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>";
+ },
+ sub {
+ my $did_order = shift;
+ my $ordernum = $did_order->ordernum;
+ my @provisioned =
+ qsearch({ table => 'phone_avail',
+ hashref => { 'ordernum' => $ordernum, },
+ select => 'phone_avail.*',
+ extra_sql => ' and svcnum is not null ',
+ });
+ return ''
+ unless $did_order->received
+ && $did_order->custnum
+ && !scalar(@provisioned);
+ include( '/elements/popup_link.html',
+ { 'action' => "${p}misc/did_order_provision.html?ordernum=".$did_order->ordernum,
+ 'label' => 'Provision All DIDs',
+ 'actionlabel' => 'Bulk DID order - DID provisioning',
+ 'width' => 520,
+ 'height' => 300,
+ }
+ )
+ },
+ sub {
+ my $did_order = shift;
+ return '' unless !$did_order->received;
+ qq!<A HREF="javascript:areyousure('${p}misc/did_order_confirmed.html?action=cancel;ordernum=!
+ . $did_order->ordernum . qq!', 'Cancel this order (#!
+ . $did_order->ordernum . qq!)?')">Cancel</A>!
+ },
+ ],
'links' => [
- [ $p.'edit/did_order.html?', 'ordernum' ],
- ],
+ [ $p.'edit/did_order.html?', 'ordernum' ],
+ ],
+ 'html_foot' => '
+ <script type="text/javascript">
+ function areyousure(href,msg) {
+ if (confirm(msg))
+ window.location.href = href;
+ }
+ </script>
+ ',
)
%>
<%init>
@@ -24,50 +98,10 @@ die "access denied"
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>
diff --git a/httemplate/edit/did_order.html b/httemplate/edit/did_order.html
index f20e34708..cbd33007d 100644
--- a/httemplate/edit/did_order.html
+++ b/httemplate/edit/did_order.html
@@ -65,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 ratecenter state quantity );
+ my @fields = qw( msanum npa latanum ratecenternum state quantity );
my @gfields = ( '', map "_$_", @fields );
map {
@@ -111,6 +111,22 @@ my $javascript = <<END;
custnum.value = '';
custnum_search.value = '';
}
+
+ /* o2m or something else is broken, can't put this in the actual
+ component because random JS and other crap is rendered
+ onto the final output page */
+ function ratecenter_changed(rc) {
+ var idbase = rc.id.substring(0,rc.id.indexOf('_'));
+ var div = document.getElementById(idbase+'_rc_div');
+ var input = document.getElementById(idbase+'_rc_new');
+ if(rc.options[rc.selectedIndex].value == '0') {
+ div.style.display = 'inline';
+ }
+ else {
+ div.style.display = 'none';
+ }
+ input.value = '';
+ }
</SCRIPT>
END
diff --git a/httemplate/edit/process/did_order.html b/httemplate/edit/process/did_order.html
index 1762cfa25..a7d30c36c 100644
--- a/httemplate/edit/process/did_order.html
+++ b/httemplate/edit/process/did_order.html
@@ -4,7 +4,8 @@
'value_callback' => $value_callback,
'process_o2m' => {
'table' => 'did_order_item',
- 'fields' => \@item_fields,
+ 'fields' => [ qw( msanum npa latanum ratecenternum state
+ quantity ) ],
},
)
%>
@@ -22,6 +23,16 @@ my $value_callback = sub {
($field =~ /ed$/ && $value !~ /^\d+$/) ? parse_datetime($value) : $value;
};
-my @item_fields = qw( msa npa latanum ratecenter state quantity );
+my @params = $cgi->param;
+foreach my $param ( @params ) {
+ next unless $param =~ /^(orderitemnum[0-9]+)_rc_new$/;
+ my $prefix = $1;
+ my $value = $cgi->param($param);
+ next unless $value =~ /^[A-Za-z0-9\- ]+$/;
+ my $rc = new FS::rate_center({ description => $value });
+ my $error = $rc->insert;
+ die "error inserting new rate center: $error" if $error;
+ $cgi->param("${prefix}_ratecenternum",$rc->ratecenternum);
+}
</%init>
diff --git a/httemplate/elements/did_order_item.html b/httemplate/elements/did_order_item.html
index 0f5a76516..00668f94f 100644
--- a/httemplate/elements/did_order_item.html
+++ b/httemplate/elements/did_order_item.html
@@ -4,24 +4,70 @@
<TABLE>
<TR>
-% foreach my $field ( @textfields ) {
-%
-% my $value = '';
-% $value = $item->get($field);
+% my $value = '';
- <TD>
+% $value = $item->get('quantity');
+ <TD>
<INPUT TYPE = "text"
- NAME = "<%$name%>_<%$field%>"
- ID = "<%$id%>_<%$field%>"
- SIZE = "<% $size{$field} || 15 %>"
- VALUE = "<% scalar($cgi->param($name."_$field"))
+ NAME = "<%$name%>_quantity"
+ ID = "<%$id%>_quantity"
+ SIZE = "3"
+ VALUE = "<% scalar($cgi->param($name."_quantity"))
|| $value |h %>"
- <% $onchange %>
>
- <BR><FONT SIZE="-1"><% $label{$field} %></FONT>
- </TD>
-% }
-% my $value = '';
+ <BR><FONT SIZE="-1">Quantity</FONT>
+ </TD>
+
+% $value = $item->get('npa');
+ <TD>
+ <INPUT TYPE = "text"
+ NAME = "<%$name%>_npa"
+ ID = "<%$id%>_npa"
+ SIZE = "3"
+ VALUE = "<% scalar($cgi->param($name."_npa"))
+ || $value |h %>"
+ >
+ <BR><FONT SIZE="-1">NPA</FONT>
+ </TD>
+
+% $value = $item->get('ratecenternum');
+ <TD>
+ <% include('/elements/select-table.html',
+ 'name_col' => 'description',
+ 'table' => 'rate_center',
+ 'disable_empty' => 0,
+ 'empty_label' => ' ',
+ 'field' => "${name}_ratecenternum",
+ 'id' => "${id}_ratecenternum",
+ 'curr_value' => scalar($cgi->param("${name}_ratecenternum"))
+ || $value,
+ 'post_options' => [ 0 => 'Add new...' ],
+ onchange => 'ratecenter_changed',
+ )
+ %>
+ <BR><FONT SIZE="-1">Rate Center</FONT>
+ <div style="display:none; font-size: 80%" id="<%$id%>_rc_div">
+ - add new: <INPUT TYPE = "text"
+ NAME = "<%$name%>_rc_new"
+ ID = "<%$id%>_rc_new">
+ </div>
+ </TD>
+
+% $value = $item->get('msanum');
+ <TD>
+ <% include('/elements/select-table.html',
+ 'name_col' => 'description',
+ 'table' => 'msa',
+ 'disable_empty' => 0,
+ 'empty_label' => ' ',
+ 'field' => "${name}_msanum",
+ 'curr_value' => scalar($cgi->param("${name}_msanum"))
+ || $value,
+ )
+ %>
+ <BR><FONT SIZE="-1">MSA</FONT>
+ </TD>
+
% $value = $item->get('latanum');
<TD><% include('/elements/select-table.html',
'name_col' => 'description',
@@ -32,10 +78,11 @@
'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,
@@ -44,10 +91,11 @@
'prefix' => "${name}_",
'state' => scalar($cgi->param("${name}_state"))
|| $value,
- )
+ )
%>
<BR><FONT SIZE="-1">State</FONT>
</TD>
+
</TR>
</TABLE>
@@ -61,15 +109,6 @@ my $id = $opt{'id'} || 'orderitemnum';
my $curr_value = $opt{'curr_value'} || $opt{'value'};
-my $onchange = '';
-if ( $opt{'onchange'} ) {
- $onchange = $opt{'onchange'};
- $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/;
- $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange
- #callbacks should act the same
- $onchange = 'onChange="'. $onchange. '"';
-}
-
my $item;
if ( $curr_value ) {
$item = qsearchs('did_order_item', { 'orderitemnum' => $curr_value } );
@@ -77,15 +116,4 @@ if ( $curr_value ) {
$item = new FS::did_order_item {};
}
-my %size = ( 'npa' => 3,
- 'quantity' => 3,);
-
-tie my %label, 'Tie::IxHash',
- 'quantity' => 'Quantity',
- 'npa' => 'NPA',
- 'ratecenter' => 'Rate Center',
- 'msa' => 'MSA',
-;
-my @textfields = keys %label;
-
</%init>
diff --git a/httemplate/misc/did_order_confirm.html b/httemplate/misc/did_order_confirm.html
index 40495a5e9..e55958d8c 100644
--- a/httemplate/misc/did_order_confirm.html
+++ b/httemplate/misc/did_order_confirm.html
@@ -4,6 +4,7 @@
<FORM NAME="did_order_confirm" ACTION="<% popurl(1) %>did_order_confirmed.html" METHOD=POST>
<INPUT TYPE="hidden" NAME="ordernum" VALUE="<% $ordernum %>">
+<INPUT TYPE="hidden" NAME="action" VALUE="confirm">
<TABLE>
<TR>
<TD>Order #</TD>
diff --git a/httemplate/misc/did_order_confirmed.html b/httemplate/misc/did_order_confirmed.html
index 53a41a738..aaded9f58 100644
--- a/httemplate/misc/did_order_confirmed.html
+++ b/httemplate/misc/did_order_confirmed.html
@@ -1,6 +1,6 @@
-<% include('/elements/header-popup.html', "DID order confirmed") %>
+<% include('/elements/header-popup.html', $success_msg ) %>
<SCRIPT TYPE="text/javascript">
- window.top.location.reload();
+ <% $js %>
</SCRIPT>
</BODY>
</HTML>
@@ -8,6 +8,12 @@
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Import');
+$cgi->param('action') =~ /^(confirm|cancel)$/ or die 'illegal action';
+my $action = $1;
+my $success_msg = '';
+my $error = '';
+my $js = 'window.top.location.reload();';
+
$cgi->param('ordernum') =~ /^(\d+)$/ or die 'illegal ordernum';
my $ordernum = $1;
my $did_order = qsearchs( {
@@ -16,22 +22,27 @@ my $did_order = qsearchs( {
} );
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;
+if ( $action eq 'confirm' ) {
+ my $confirmed = '';
+ my $sucess_msg = 'DID order 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+)$/;
-my $error = '';
-$did_order->confirmed($confirmed);
-$did_order->vendor_order_id($cgi->param('vendor_order_id'));
-$error = $did_order->replace;
+ die "invalid confirmation date" unless $confirmed;
-if ( $error ) {
- $cgi->param('error', $error);
- print $cgi->redirect(popurl(1). "did_order_confirm.html?". $cgi->query_string );
+ $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 );
+ }
+}
+elsif ( $action eq 'cancel' ) {
+ my $sucess_msg = 'DID order cancelled';
+ $error = $did_order->delete;
+ $js = "window.location.href = '${p}browse/did_order.html'";
}
-
</%init>
diff --git a/httemplate/misc/did_order_provision.html b/httemplate/misc/did_order_provision.html
new file mode 100644
index 000000000..b0c7210b7
--- /dev/null
+++ b/httemplate/misc/did_order_provision.html
@@ -0,0 +1,35 @@
+<% include('/elements/header-popup.html', 'Bulk DID order - DID provisioning' ) %>
+
+<% include('/elements/error.html') %>
+
+<FORM NAME="did_order_confirm" ACTION="<% popurl(1) %>did_order_confirmed.html" METHOD=POST>
+<INPUT TYPE="hidden" NAME="action" VALUE="provision">
+<INPUT TYPE="hidden" NAME="ordernum" VALUE="<% $ordernum %>">
+<TABLE>
+ <TR>
+ <TD>Order #</TD>
+ <TD><% $ordernum %></TD>
+ </TR>
+ <TR>
+ <TD COLSPAN="2"><INPUT TYPE="SUBMIT" value="Provision"></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;
+
+die "Order is not in received status and/or DIDs not assigned to a customer"
+ unless $did_order->received && $did_order->custnum;
+
+
+</%init>