summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-05-14 00:28:55 -0700
committerIvan Kohler <ivan@freeside.biz>2013-05-14 00:28:55 -0700
commit7c301b704d8afbdac5760111d668eeda1ca40901 (patch)
tree7db4f49f9577a24fbf2d7b49987d42d75cb7d80c /httemplate
parentc1f7dc4627e48b52e059c79fcae24873bec733da (diff)
svc_cable, RT#22009
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/docs/part_svc-table.html1
-rw-r--r--httemplate/edit/cable_device.html114
-rw-r--r--httemplate/edit/process/cable_device.html23
-rw-r--r--httemplate/view/elements/svc_Common.html5
-rw-r--r--httemplate/view/elements/svc_devices.html10
-rw-r--r--httemplate/view/svc_phone.cgi1
6 files changed, 150 insertions, 4 deletions
diff --git a/httemplate/docs/part_svc-table.html b/httemplate/docs/part_svc-table.html
index 48841f550..8d3711d23 100644
--- a/httemplate/docs/part_svc-table.html
+++ b/httemplate/docs/part_svc-table.html
@@ -21,6 +21,7 @@
<UL STYLE="margin:0">
<LI><B>svc_dsl</B>: DSL
<LI><B>svc_broadband</B>: Wireless broadband
+ <LI><B>svc_cable</B>: Cable
<LI><B>svc_dish</B>: DISH Network
</UL>
</TD>
diff --git a/httemplate/edit/cable_device.html b/httemplate/edit/cable_device.html
new file mode 100644
index 000000000..eb91ad728
--- /dev/null
+++ b/httemplate/edit/cable_device.html
@@ -0,0 +1,114 @@
+<% include( 'elements/edit.html',
+ 'name' => 'Cable device',
+ 'table' => 'cable_device',
+ 'labels' => {
+ 'devicenum' => 'Device',
+ 'devicepart' => 'Device type',
+ 'mac_addr' => 'MAC address',
+ 'serial' => 'Serial number',
+ },
+ 'fields' => [ { 'field' => 'devicepart',
+ 'type' => 'select-table',
+ 'table' => 'part_device',
+ 'name_col' => 'devicename',
+ 'onchange' => 'devicepart_changed',
+ 'empty_label' =>'Select device type',
+ #'hashref' =>{ disabled => '' },
+ },
+ { field => 'mac_addr',
+ type => 'select-mac',
+ },
+ { 'field' => 'svcnum',
+ 'type' => 'hidden',
+ },
+ ],
+ 'menubar' => [], #disable viewall
+ #'viewall_dir' => 'browse',
+ 'new_callback' => sub {
+ my( $cgi, $object ) = @_;
+ $object->svcnum( $cgi->param('svcnum') );
+ },
+ 'html_foot' => $html_foot,
+ )
+%>
+<%init>
+
+#bad: pretty much entirely false laziness w/phone_device, except for labels and
+# the serial field
+
+my @deviceparts_with_inventory =
+ map $_->devicepart,
+ qsearch({ 'table' => 'part_device',
+ 'extra_sql' => 'WHERE inventory_classnum IS NOT NULL',
+ });
+
+my $html_foot = sub {
+ my $js = "
+<SCRIPT TYPE=\"text/javascript\">
+
+ function opt(what,value,text) {
+ var optionName = new Option(text, value, false, false);
+ var length = what.length;
+ what.options[length] = optionName;
+ }
+
+ function devicepart_changed(what){
+
+ var macsel = document.getElementById('sel_mac_addr');
+ var mac = document.getElementById('mac_addr');
+
+ function update_macs(macs) {
+ for ( var i = macsel.length; i >= 0; i-- )
+ macsel.options[i] = null;
+
+ var macArray = eval('(' + macs + ')' );
+ if(macArray.length == 0)
+ opt(macsel,'','No MAC addresses found in inventory for this device type');
+ else
+ opt(macsel,'','Select MAC address');
+
+ for ( var i = 0; i < macArray.length; i++ ) {
+ opt(macsel,macArray[i],macArray[i]);
+ }
+
+ }
+
+ var devicepart = what.options[what.selectedIndex].value;
+
+ var deviceparts_with_inventory = new Array(";
+$js .= join(',', map qq("$_"), @deviceparts_with_inventory);
+$js .= ");
+
+ var hasInventory = false;
+ for ( i = 0; i < deviceparts_with_inventory.length; i++ ) {
+ if ( deviceparts_with_inventory[i] == devicepart )
+ hasInventory = true;
+ }
+
+
+ if(hasInventory) { // do the AJAX thing, disable text field
+ macsel.style.display = 'inline';
+ mac.style.display = 'none';
+ mac.value = '';
+ get_macs( devicepart, update_macs );
+ } else { // clear & display text field only, clear/hide select
+ mac.style.display = 'inline';
+ macsel.style.display = 'none';
+ macsel.selectedIndex = 0;
+ }
+
+ }
+
+ devicepart_changed(document.getElementById('devicepart'));
+</SCRIPT>";
+
+ $js;
+};
+
+# :/ needs agent-virt so you can't futz with arbitrary devices
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+
+</%init>
diff --git a/httemplate/edit/process/cable_device.html b/httemplate/edit/process/cable_device.html
new file mode 100644
index 000000000..97b4f81d9
--- /dev/null
+++ b/httemplate/edit/process/cable_device.html
@@ -0,0 +1,23 @@
+<% include( 'elements/process.html',
+ 'table' => 'cable_device',
+ 'redirect' => sub {
+ my( $cgi, $cable_device ) = @_;
+ #popurl(3).'view/svc_cable.html?'.
+ popurl(3).'view/svc_Common.html?svcdb=svc_cable;'.
+ 'svcnum='. $cable_device->svcnum.
+ ';devicenum=';
+ },
+ )
+%>
+<%init>
+
+if($cgi->param('sel_mac_addr') && !$cgi->param('mac_addr')) {
+ $cgi->param('mac_addr',$cgi->param('sel_mac_addr'));
+}
+
+# :/ needs agent-virt so you can't futz with arbitrary devices
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific?
+
+</%init>
diff --git a/httemplate/view/elements/svc_Common.html b/httemplate/view/elements/svc_Common.html
index 997ac142a..3c1cc66fa 100644
--- a/httemplate/view/elements/svc_Common.html
+++ b/httemplate/view/elements/svc_Common.html
@@ -119,6 +119,11 @@ function areyousure(href) {
<BR>
+<& svc_devices.html,
+ 'svc_x' => $svc_x,
+ 'table' => $svc_x->device_table,
+&>
+
% if ( defined($opt{'html_foot'}) ) {
<% ref($opt{'html_foot'})
diff --git a/httemplate/view/elements/svc_devices.html b/httemplate/view/elements/svc_devices.html
index 38c6d0919..745eabd9d 100644
--- a/httemplate/view/elements/svc_devices.html
+++ b/httemplate/view/elements/svc_devices.html
@@ -30,7 +30,7 @@
<& /elements/table-grid.html &>
<TR>
-% if ( $table eq 'phone_device' ) {
+% if ( $table eq 'phone_device' || $table eq 'cable_device' ) {
<TH CLASS="grid" BGCOLOR="#cccccc">Type</TH>
% }
<TH CLASS="grid" BGCOLOR="#cccccc">MAC Addr</TH>
@@ -58,7 +58,8 @@
% if $device->can('export_links');
<TR>
-% if ( $table eq 'phone_device' ) { #$devices->can('part_device')
+% #$devices->can('part_device')
+% if ( $table eq 'phone_device' || $svc_x->isa('FS::device_Common') ) {
<% $td %><% $device->part_device->devicename |h %></TD>
% }
<% $td %><% $device->mac_addr %></TD>
@@ -84,7 +85,7 @@ my $table = $opt{'table'}; #part_device, dsl_device
my $svc_x = $opt{'svc_x'};
my $num_part_device = 0;
-if ( $table eq 'phone_device' ) {
+if ( $table eq 'phone_device' || $table eq 'cable_device' ) {
my $sth = dbh->prepare("SELECT COUNT(*) FROM part_device")
#WHERE disabled = '' OR disabled IS NULL;");
or die dbh->errstr;
@@ -92,6 +93,7 @@ if ( $table eq 'phone_device' ) {
$num_part_device = $sth->fetchrow_arrayref->[0];
}
-my @devices = $svc_x->$table();
+my @devices = $svc_x->isa('FS::device_Common') ? $svc_x->device_objects()
+ : $svc_x->$table();
</%init>
diff --git a/httemplate/view/svc_phone.cgi b/httemplate/view/svc_phone.cgi
index ed95c4cea..408364aeb 100644
--- a/httemplate/view/svc_phone.cgi
+++ b/httemplate/view/svc_phone.cgi
@@ -67,6 +67,7 @@ my $html_foot = sub {
###
# Devices
###
+ #remove this when svc_phone isa device_Common, as elements/svc_Common will display it
my $devices = include('/view/elements/svc_devices.html',
'svc_x' => $svc_phone,
'table' => 'phone_device',