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

@ -1369,7 +1369,7 @@ sub insert_pos(){
if($ct->{template_id} && $ct->{template_id} == 205){#Leihrad_list
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt01,txt08,txt02,txt09,txt12,itime,start_time,end_time,int02,int03,int06,int04,txt05,txt06,txt07,int10,int12,int13,owner,int07,txt04,int09,int17,int15,int16,int11,int18,int19,txt17,txt18,int20,int25,int34,txt22,txt10,int35,int36,int37,time01,time02) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$ct->{txt01}','$user_name','$ct->{txt02}','$ctadr->{txt09}','$prefix',now(),now(),'$endRental','$unit_price','$menge','$station','$station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$daymax_price','$abo_price','$free_hours','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','$ct->{int20}','$trackon','$staff','$sig_book->{bikeId}','$sig_book->{reservationId}','$unit_price1','$unit_price2','$start_price','$unit_time','$free_time') RETURNING c_id");
}else{
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt08,txt09,itime,int02,int03,txt01,txt06,txt07,int10,int12,owner) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','0','$user_name','$ctadr->{txt09}',now(),'$unit_price1','1','$ct->{txt01}','$ct->{txt06}','$ct->{txt07}','0','$from_main_id','$owner') RETURNING c_id");
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt08,txt09,itime,int02,int03,txt01,txt06,txt07,int10,int12,owner) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','0','$user_name','$ctadr->{txt09}',now(),'$unit_price','1','$ct->{txt01}','$ct->{txt06}','$ct->{txt07}','0','$from_main_id','$owner') RETURNING c_id");
}
my $rows = $sth->execute();
my $last_id;

View file

@ -562,7 +562,7 @@ sub price2calc {
my $ctpos = shift;
my $total = 0;
my $discount = 0;
my $discount = "";
my $einzel = $ctpos->{int02} || 0;
my $menge = $ctpos->{int03} || 0;
my $discount_val = $ctpos->{int07} || 0;

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");

View file

@ -494,8 +494,17 @@ Nach Abschluss der Registrierung erhalten Sie sowohl auf die von Ihnen hinterleg
#start failure messages
#Gutschein
if($key =~ /txt16/ && $ctrel->{c_id}){
$required="";
$label_des = "<span style='font-weight:normal;'>$des</span>";
if($R::failure =~ /^txt16/){
$autofocus = "autofocus";
$label_des = "<span style=color:$red>Der Gutscheincode ist leider nicht vorhanden. Bei nicht vorhandenen Codes das Feld bitte leer lassen.</span>";
}
elsif($R::failure =~ /conflict_txt16/){
$autofocus = "autofocus";
$label_des = "<span style=color:$red>Der Gutscheincode wurde bereits hinterlegt. Bei nicht vorhandenen Codes das Feld bitte leer lassen.</span>";
}else{
$required="";
$label_des = "<span style='font-weight:normal;'>$des</span>";
}
}
elsif($key eq "txt08" && $R::failure && $R::failure =~ /conflict_txt08/){
$autofocus = "autofocus";