summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/cust_main_note.cgi
blob: 8b9105bd87ec6ea0d2e5f2209fc8d698315e4d6d (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
%
%
%$cgi->param('custnum') =~ /^(\d+)$/
%  or die "Illegal custnum: ". $cgi->param('custnum');
%my $custnum = $1;
%
%$cgi->param('notenum') =~ /^(\d*)$/
%  or die "Illegal notenum: ". $cgi->param('notenum');
%my $notenum = $1;
%
%my $otaker = $FS::CurrentUser::CurrentUser->name;
%$otaker = $FS::CurrentUser::CurrentUser->username
%  if ($otaker eq "User, Legacy");
%
%my $new = new FS::cust_main_note ( {
%  notenum  => $notenum,
%  custnum  => $custnum,
%  _date    => time,
%  otaker   => $otaker,
%  comments =>  $cgi->param('comment'),
%} );
%
%my $error;
%if ($notenum){
%  my $old  = qsearchs('cust_main_note', { 'notenum' => $notenum });
%  $error = "No such note: $notenum" unless $old;
%  unless($error){
%    map { $new->$_($old->$_) } ('_date', 'otaker');
%    $error = $new->replace($old);
%  }
%}else{
%  $error = $new->insert;
%}
%
%if ($error) {
%  $cgi->param('error', $error);
%  print $cgi->redirect(popurl(2). 'cust_main_note.cgi?'. $cgi->query_string );
%}
%
%    
<% header('Note ' . ($notenum ? 'updated' : 'added') ) %>
    <SCRIPT TYPE="text/javascript">
      parent.cust_main_notes.location.reload();
      try{parent.cust_main_notes.cClick()}
      catch(err){}
      try{parent.cClick()}
      catch(err){}
    </SCRIPT>
    </BODY></HTML>
%
%