ugh, too restrictive
[freeside.git] / httemplate / edit / process / cust_main_note.cgi
1 %
2 %
3 %$cgi->param('custnum') =~ /^(\d+)$/
4 %  or die "Illegal custnum: ". $cgi->param('custnum');
5 %my $custnum = $1;
6 %
7 %$cgi->param('notenum') =~ /^(\d*)$/
8 %  or die "Illegal notenum: ". $cgi->param('notenum');
9 %my $notenum = $1;
10 %
11 %my $otaker = $FS::CurrentUser::CurrentUser->name;
12 %$otaker = $FS::CurrentUser::CurrentUser->username
13 %  if ($otaker eq "User, Legacy");
14 %
15 %my $new = new FS::cust_main_note ( {
16 %  notenum  => $notenum,
17 %  custnum  => $custnum,
18 %  _date    => time,
19 %  otaker   => $otaker,
20 %  comments =>  $cgi->param('comment'),
21 %} );
22 %
23 %my $error;
24 %if ($notenum){
25 %  my $old  = qsearchs('cust_main_note', { 'notenum' => $notenum });
26 %  $error = "No such note: $notenum" unless $old;
27 %  unless($error){
28 %    map { $new->$_($old->$_) } ('_date', 'otaker');
29 %    $error = $new->replace($old);
30 %  }
31 %}else{
32 %  $error = $new->insert;
33 %}
34 %
35 %if ($error) {
36 %  $cgi->param('error', $error);
37 %  print $cgi->redirect(popurl(2). 'cust_main_note.cgi?'. $cgi->query_string );
38 %}
39 %
40 %    
41 <% header('Note ' . ($notenum ? 'updated' : 'added') ) %>
42     <SCRIPT TYPE="text/javascript">
43       window.top.location.reload();
44     </SCRIPT>
45
46     </BODY></HTML>
47 %
48 %
49