use utf8;
use warnings; no warnings "redefine";
use strict;
use Loader qw(line_in log_update);
use Dbase::Help qw(Do DoFn qquote);

sub set_acct_text($$;$) {
	my($hash,$seq,$kn) = @_;
	my($id,$otxt) = DoFn("select acct.kunde,acctassoc.info from acct left join acctassoc on acct.`hash`=acctassoc.`hash` and acct.seq=acctassoc.seq where acct.`hash`=$hash and acct.seq=$seq");

	my $kk = line_in "Text: "; return undef if $kk eq "";
	
	log_update("acct","hash",$hash,"seq",$seq,undef,"txt",undef,$otxt);

	my $atid = DoFn("select id from acctassoc where `hash`=$hash and seq=$seq");
	if($kk) {
		if($atid) {
			Do("update acctassoc set info=${\qquote $kk} where id=$atid");
		} else {
			Do("insert into acctassoc set `hash`=$hash, seq=$seq, info=${\qquote $kk}");
		}
	} else {
		Do("update acctassoc set info=NULL where id=$atid") if $atid;
	}

	Do("update kunde set geaendert=UNIX_TIMESTAMP(NOW()) where id=$id") if $id > 0;
}
1;
