diff options
Diffstat (limited to 'httemplate/view')
-rw-r--r-- | httemplate/view/elements/svc_devices.html | 102 | ||||
-rw-r--r-- | httemplate/view/svc_dsl.cgi | 65 |
2 files changed, 140 insertions, 27 deletions
diff --git a/httemplate/view/elements/svc_devices.html b/httemplate/view/elements/svc_devices.html new file mode 100644 index 000000000..d71c82f07 --- /dev/null +++ b/httemplate/view/elements/svc_devices.html @@ -0,0 +1,102 @@ +<%doc> + +#Example: + + include( 'elements/svc_devices.html', + #required + 'svc_x' => $svc_phone, #or $svc_dsl + 'table' => 'phone_device', #or dsl_device + + #optional + 'no_edit' => 0, #set true to turn off edit link + ) + +</%doc> +<% $devices %> +<%init> + + my %opt = @_; + my $table = $opt{'table'}; #part_device, dsl_device + my $svc_x = $opt{'svc_x'}; + + my $devices = ''; + + my $num_part_device = 0; + if ( $table eq 'phone_device' ) { + my $sth = dbh->prepare("SELECT COUNT(*) FROM part_device") + #WHERE disabled = '' OR disabled IS NULL;"); + or die dbh->errstr; + $sth->execute or die $sth->errstr; + $num_part_device = $sth->fetchrow_arrayref->[0]; +} + + my @devices = $svc_x->$table(); + + #should move the below to proper mason code above instead of making $devices + if ( @devices || $num_part_device || $table eq 'dsl_device' ) { + my $svcnum = $svc_x->svcnum; + $devices .= + qq[Devices (<A HREF="${p}edit/$table.html?svcnum=$svcnum">Add device</A>)<BR>]; + if ( @devices ) { + + $devices .= qq! + <SCRIPT> + function areyousure(href) { + if (confirm("Are you sure you want to delete this device?") == true) + window.location.href = href; + } + </SCRIPT> + !; + + + $devices .= + include('/elements/table-grid.html'). + '<TR>'; + + $devices .= + '<TH CLASS="grid" BGCOLOR="#cccccc">Type</TH>' + if $table eq 'phone_device'; + + $devices .= + '<TH CLASS="grid" BGCOLOR="#cccccc">MAC Addr</TH>'. + '<TH CLASS="grid" BGCOLOR="#cccccc"></TH>'. + '<TH CLASS="grid" BGCOLOR="#cccccc"></TH>'. + '</TR>'; + my $bgcolor1 = '#eeeeee'; + my $bgcolor2 = '#ffffff'; + my $bgcolor = ''; + + foreach my $device ( @devices ) { + + if ( $bgcolor eq $bgcolor1 ) { + $bgcolor = $bgcolor2; + } else { + $bgcolor = $bgcolor1; + } + my $td = qq(<TD CLASS="grid" BGCOLOR="$bgcolor">); + + my $devicenum = $device->devicenum; + my $export_links = join( '<BR>', @{ $device->export_links } ) + if $device->can('export_links'); + + $devices .= '<TR>'; + $devices .= $td. $device->part_device->devicename. '</TD>' + if $table eq 'phone_device'; #$devices->can('part_device'); + + $devices .= $td. $device->mac_addr. '</TD>'. + $td. $export_links. '</TD>'. + "$td( "; + + $devices .= qq(<A HREF="${p}edit/$table.html?$devicenum">edit</A> | ) + unless $opt{'no_edit'}; + + $devices .= qq(<A HREF="javascript:areyousure('${p}misc/delete-$table.html?$devicenum')">delete</A>). + ' )</TD>'. + '</TR>'; + } + $devices .= '</TABLE><BR>'; + } + $devices .= '<BR>'; + } + +</%init> diff --git a/httemplate/view/svc_dsl.cgi b/httemplate/view/svc_dsl.cgi index 9d9134a4d..477da268b 100644 --- a/httemplate/view/svc_dsl.cgi +++ b/httemplate/view/svc_dsl.cgi @@ -33,33 +33,44 @@ my $svc_cb = sub { # if no DSL-pulling exports, then just display everything, which is the # default behaviour implemented above - return if ( scalar(@exports) == 0 ); - - my $export = @exports[0]; - - @fields = ( 'phonenum', - { field => 'loop_type', - value => 'FS::part_export::'.$export->exporttype.'::loop_type_long' - }, - { field => 'desired_due_date', type => 'date', }, - { field => 'due_date', type => 'date', }, - { field => 'pushed', type => 'datetime', }, - { field => 'monitored', type => 'checkbox', }, - { field => 'last_pull', type => 'datetime', }, - 'first', - 'last', - 'company' ); - - my $status = ''; - if($export->exporttype eq 'ikano') { - push @fields, qw ( username password isp_chg isp_prev staticips ); - $status = "Ikano " . $svc_dsl->vendor_order_type . " order #" - . $svc_dsl->vendor_order_id . " Status: " - . $svc_dsl->vendor_order_status; - } - # else add any other export-specific stuff here + if ( scalar(@exports) ) { + + my $export = @exports[0]; + + @fields = ( + 'phonenum', + { field => 'loop_type', + value => 'FS::part_export::'.$export->exporttype.'::loop_type_long' + }, + { field => 'desired_due_date', type => 'date', }, + { field => 'due_date', type => 'date', }, + { field => 'pushed', type => 'datetime', }, + { field => 'monitored', type => 'checkbox', }, + { field => 'last_pull', type => 'datetime', }, + 'first', + 'last', + 'company', + ); + + my $status = ''; + if($export->exporttype eq 'ikano') { + push @fields, qw ( username password isp_chg isp_prev staticips ); + $status = "Ikano " . $svc_dsl->vendor_order_type . " order #" + . $svc_dsl->vendor_order_id . " Status: " + . $svc_dsl->vendor_order_status; + } + # else add any other export-specific stuff here - $footer = "<B>$status</B>"; + $footer = "<B>$status</B>"; + + } + + $footer .= '<BR><BR>'. + include( '/view/elements/svc_devices.html', + 'svc_x' => $svc_dsl, + 'table' => 'dsl_device', + 'no_edit' => 1, + ); my @notes = $svc_dsl->notes; if ( @notes ) { @@ -68,7 +79,7 @@ my $svc_cb = sub { my $date_format = $conf->config('date_format') || '%m/%d/%Y'; $footer .= - "<BR><BR>Order Notes<BR>". ntable('#cccccc', 2). #id="dsl_notes" + "Order Notes<BR>". ntable('#cccccc', 2). #id="dsl_notes" '<TR><TH>Date</TH><TH>By</TH><TH>Priority</TH><TH>Note</TH></TR>'; foreach my $note ( @notes ) { |