summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/agent_type.cgi
blob: ad5963b31365a656b4490f7f15ea4110012d3c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
%if ( $error ) {
%  $cgi->param('error', $error);
<% $cgi->redirect(popurl(2). "agent_type.cgi?". $cgi->query_string ) %>
%} else {
<% $cgi->redirect(popurl(3). "browse/agent_type.cgi") %>
%}
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');

my $typenum = $cgi->param('typenum');
my $old = qsearchs('agent_type',{'typenum'=>$typenum}) if $typenum;

my $new = new FS::agent_type ( {
  map {
    $_, scalar($cgi->param($_));
  } fields('agent_type')
} );

my $error;
if ( $typenum ) {
  $error = $new->replace($old);
} else {
  $error    = $new->insert;
  $typenum  = $new->getfield('typenum');
}

  $error ||= $new->process_m2m(
    'link_table'   => 'type_pkgs',
    'target_table' => 'part_pkg',
    'params'       => scalar($cgi->Vars)
  );

</%init>