#!/usr/bin/perl

use strict;
use CGI;

use Opals::Context;
use Opals::Template_ajax qw(
    tmpl_read
    tmpl_write
);
use Opals::Locale qw(
    loc_getMsgFile
    loc_write
);


 
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/portlet/saveBeginnerBoxDB.tmpl',
    }
);


    my $boxId       = $input->{"boxId"};
    my $title       = $input->{"beginner_title"};
       $title       =~ s/[\r\n]//g;
    my $url         = $input->{"beginner_url"};
       $url         =~ s/[\r\n]//g;
    my $description = $input->{"beginner_description"};

    my $sth=$dbh->prepare("replace into opl_beginnerDBLk set boxId=? ,title=?, url=?, description=?");
    my $rv =$sth->execute($boxId,$title,$url,$description);  
    
    $sth->finish;  
    my $status = ($rv eq '0E0') ? 0 : 1;        
    $template->param(
        status => $status,
        boxId  => $boxId
    );


tmpl_write($dbh, $cgi, $cookie, $template);


