1 <& /elements/header.html, "$action Service Definition" &>
2 <& /elements/menubar.html,
3 'View all service definitions' => "${p}browse/part_svc.cgi"
4 #" onLoad=\"visualize()\""
7 <& /elements/init_overlib.html &>
11 <STYLE TYPE="text/css">
13 background-color: #dddddd;
19 background-color: #ffffff;
22 background-color: #eeeeee;
25 background-color: #ffffff;
38 <SCRIPT TYPE="text/javascript">
39 // copy all fields from the outer form (svc and its localizations, plus
40 // preserve, selfservice_access, etc.) into the inner form, creating hidden
42 function fixup_submit(layer) {
43 var layer_form = $(document.forms[layer]);
44 var main_form = $(document.forms['SvcEditMain']);
45 var data = main_form.serializeArray();
46 for (var i = 0; i < data.length; i++) {
47 var input = layer_form.children('[name=' + data[i].name + ']');
49 input.prop('value', data[i].value);
51 $( '<input type="hidden">' )
52 .attr('name', data[i].name)
53 .prop('value', data[i].value)
54 .appendTo(layer_form);
57 layer_form[0]['submit'].disabled = true;
58 //fixup(document.forms[layer]);
59 window[layer+'process'].call();
62 function flag_changed(obj) {
63 var newflag = obj.value;
64 var a = obj.name.match(/(.*)__(.*)_flag/);
67 var input = document.getElementById(layer + '__' + field);
68 // for fields that have both 'input' and 'select', 'select' is 'select from
70 var select = document.getElementById(layer + '__' + field + '_select');
71 if (newflag == "" || newflag == "X") { // disable
73 input.disabled = true;
74 input.className = 'disabled';
77 select.disabled = true;
78 select.className = 'hidden';
80 } else if ( newflag == 'D' || newflag == 'F' || newflag == 'S' ) {
82 // enable text box, disable inventory select
83 input.disabled = false;
84 input.className = 'enabled';
86 select.disabled = false;
87 select.className = 'hidden';
89 } else if ( select ) {
91 select.disabled = false;
92 select.className = 'enabled';
93 if ( newflag == 'S' || select.getAttribute('should_be_multiple') ) {
94 select.multiple = true;
95 var defaults = select.getAttribute('default');
97 defaults = defaults.split(',');
98 for (var i = 0; i < defaults.length; i++) {
99 for (j = 0; j < select.options.length; j++ ) {
100 if ( defaults[i] == select.options[j].value ) {
101 select.options[j].selected = true;
107 select.multiple = false;
110 } else if ( newflag == 'M' || newflag == 'A' || newflag == 'H' ) {
111 // these all require a class selection
113 select.disabled = false;
114 select.className = 'enabled';
116 input.disabled = false;
117 input.className = 'hidden';
121 var required = document.getElementById(layer + '__' + field + '_required');
122 if (required && !required.disabledinit) {
123 if (newflag == "F") {
124 required.checked = false;
125 required.disabled = true;
127 required.disabled = false;
132 window.onload = function() {
133 var selects = document.getElementsByTagName('SELECT');
134 for(i = 0; i < selects.length; i++) {
135 var obj = selects[i];
136 if ( obj.multiple ) {
137 obj.setAttribute('should_be_multiple', true);
140 var inputs = document.getElementsByTagName('INPUT');
141 for(i = 0; i < inputs.length; i++) {
143 if (obj.type == 'checkbox') {
144 if ( obj.name.match(/_required$/) ) {
145 if ( obj.disabled ) {
146 obj.disabledinit = 1;
151 for(i = 0; i < selects.length; i++) {
152 var obj = selects[i];
153 if ( obj.name.match(/_flag$/) ) {
161 <FORM NAME="SvcEditMain">
163 <FONT CLASS="fsinnerbox-title">Service Part #<% $part_svc->svcpart ? $part_svc->svcpart : "(NEW)" %></FONT>
164 <TABLE CLASS="fsinnerbox">
165 <& /elements/tr-input-locale-text.html,
166 'object' => $part_svc,
169 'label' => 'Service',
170 'curr_value' => $hashref->{svc},
173 %# <TD ALIGN="right">Service</TD>
174 %# <TD><INPUT TYPE="text" NAME="svc" VALUE="<% $hashref->{svc} %>"></TD>
177 <& /elements/tr-select-part_svc_class.html, curr_value=>$hashref->{classnum} &>
180 <TH ALIGN="right">Self-service access</TD>
182 <SELECT NAME="selfservice_access">
183 % tie my %selfservice_access, 'Tie::IxHash', #false laziness w/browse/part_svc
185 % 'hidden' => 'Hidden',
186 % 'readonly' => 'Read-only',
188 % for (keys %selfservice_access) {
189 <OPTION VALUE="<% $_ %>"
190 <% $_ eq $hashref->{'selfservice_access'} ? 'SELECTED' : '' %>
191 ><% $selfservice_access{$_} %>
199 <TH ALIGN="right">Disable new orders</TD>
200 <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>></TD>
204 <TH ALIGN="right">Preserve this service on package cancellation</TD>
205 <TD><INPUT TYPE="checkbox" NAME="preserve" VALUE="Y"<% $hashref->{'preserve'} eq 'Y' ? ' CHECKED' : '' %>> </TD>
210 <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $hashref->{svcpart} %>">
214 <FONT SIZE="+1"><B>Table</B></FONT> <% $widget->html %>
216 <& /elements/footer.html &>
221 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
223 my $conf = FS::Conf->new;
226 if ( $cgi->param('clone') && $cgi->param('clone') =~ /^(\d+)$/ ) {#clone
227 #$cgi->param('clone') =~ /^(\d+)$/ or die "malformed query: $query";
228 $part_svc = qsearchs('part_svc', { 'svcpart'=>$1 } )
229 or die "unknown svcpart: $1";
230 $clone = $part_svc->svcpart;
231 $part_svc->svcpart('');
232 } elsif ( $cgi->keywords ) { #edit
233 my($query) = $cgi->keywords;
234 $query =~ /^(\d+)$/ or die "malformed query: $query";
235 $part_svc=qsearchs('part_svc', { 'svcpart'=>$1 } )
236 or die "unknown svcpart: $1";
238 $part_svc = new FS::part_svc {};
241 my $action = $part_svc->svcpart ? 'Edit' : 'Add';
242 my $hashref = $part_svc->hashref;
243 # my $p_svcdb = $part_svc->svcdb || 'svc_acct';
246 my @dbs = $hashref->{svcdb}
247 ? ( $hashref->{svcdb} )
248 : FS::part_svc->svc_tables();
251 unless ( $hashref->{svcpart} ) {
253 include('/elements/popup_link.html',
254 'action' => $p.'docs/part_svc-table.html',
256 'actionlabel' => 'Service table help',
262 tie my %svcdb, 'Tie::IxHash', map { $_=>$_ } grep dbdef->table($_), @dbs;
263 my $widget = new HTML::Widgets::SelectLayers(
264 #'selected_layer' => $p_svcdb,
265 'selected_layer' => $hashref->{svcdb} || 'svc_acct',
266 'options' => \%svcdb,
267 'form_name' => 'SvcEditMain',
268 #'form_action' => 'process/part_svc.cgi',
269 'form_action' => 'part_svc.cgi', #self
270 # 'form_elements' => [qw( svc svcpart classnum selfservice_access
273 'html_between' => $help,
274 'layer_callback' => sub {
275 include('elements/part_svc_column.html',
277 'part_svc' => $part_svc,