#!/usr/bin/perl

#use utf8;
use strict;
use CGI;

use Opals::Context;
use Opals::Template_ajax qw(
    tmpl_read
    tmpl_write
);

use JSON;
my $dbh = Opals::Context->dbh();
END { $dbh->disconnect(); }

my $cgi = CGI->new;
my $input = $cgi->Vars();
my ($permission, $cookie, $template) = tmpl_read(
        {
            dbh             => $dbh,
            cgi             => $cgi,
            tmplFile        => 'ajax/user/saveUserNote.tmpl',
        }
);



my $uid         = $input->{'uid'};
my $userNote    = $input->{'notes'};
my $sth=$dbh->prepare("update opl_user set notes = ? where uid=?");
   $sth->execute($userNote,$uid);


print "Content-type: text/plain\n\n";
print  to_json({uid=>$uid, userNote=>$userNote},{pretty=>1});


