coupon adding masscode

This commit is contained in:
ragu 2022-05-11 19:01:13 +02:00
parent dd9be5f40e
commit de85786bc0
4 changed files with 38 additions and 12 deletions

View file

@ -714,14 +714,31 @@ sub save_transact(){
my $ctt = { c_id => 0 };
$ctt = $dbt->fetch_record($dbh_operator,$pref);
if($ctt->{c_id} > 0){
#TODO, fetch coupon in user context to restrict mass inserts
$pos_id = $dbt->insert_pos($dbh_operator,$ctt->{c_id},$ct,$ctadr_operator,"",$now_dt,$ct->{ct_name},"0",$owner);
}else{
my $ct_id = $dbt->insert_contenttrans($dbh_operator,$ctadr_operator,"300008","218","----",$owner);
$pos_id = $dbt->insert_pos($dbh_operator,$ct_id,$ct,$ctadr_operator,"",$now_dt,$ct->{ct_name},"0",$owner);
}
my $posref = {
table => "contenttrans",
table_pos => "contenttranspos",
fetch => "one",
keyfield => "c_id",
ca_id => "$ctadr->{c_id}",
ct_name => "ilike::$valxx",
};
my $cttpos = { c_id => 0 };
$cttpos = $dbt->collect_post($dbh_operator,$posref);
#check if user has still coupon used
if(!$cttpos->{c_id}){
if($ctt->{c_id} > 0){
$pos_id = $dbt->insert_pos($dbh_operator,$ctt->{c_id},$ct,$ctadr_operator,"",$now_dt,$valxx,"0",$owner);
}else{
my $ct_id = {c_id => 0};
$ct_id = $dbt->insert_contenttrans($dbh_operator,$ctadr_operator,"300008","218","----",$owner);
$pos_id = $dbt->insert_pos($dbh_operator,$ct_id,$ct,$ctadr_operator,"",$now_dt,$valxx,"0",$owner);
}
}else{
$ret = "failure::conflict_txt16#top";
}
if($pos_id){
$ret = "success::txt16";
$dbt->update_content4comp($dbh_operator,$ct->{c_id},"-","1");