mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-07-07 22:26:44 +02:00
Refactoring user registration payment methodes
This commit is contained in:
parent
dc89bed086
commit
da31898968
28 changed files with 974 additions and 2750 deletions
|
@ -1902,7 +1902,7 @@ sub bikes_available(){
|
|||
$return->{$id}->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{int04}";
|
||||
$return->{$id}->{aa_ride} = "0";
|
||||
$return->{$id}->{aa_ride} = "1" if($record_st->{$record->{$id}->{int04}}->{int42});
|
||||
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
|
||||
$return->{$id}->{uri_operator} = "$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}";
|
||||
($return->{$id}->{gps}->{latitude},$return->{$id}->{gps}->{longitude}) = split(/,/,$record->{$id}->{txt06});
|
||||
$return->{$id}->{bike} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{barcode}";
|
||||
|
||||
|
@ -2084,7 +2084,7 @@ sub bikes_all(){
|
|||
foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){
|
||||
if(1==1){
|
||||
$bikes_on_station->{$record->{$id}->{int04}}->{bike_ist} += 1;
|
||||
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
|
||||
$return->{$id}->{uri_operator} = "$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}";
|
||||
$return->{$id}->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{int04}";
|
||||
($return->{$id}->{gps}->{latitude},$return->{$id}->{gps}->{longitude}) = split(/,/,$record->{$id}->{txt06});
|
||||
$return->{$id}->{bike} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{barcode}";
|
||||
|
@ -2302,7 +2302,7 @@ sub stations_available(){
|
|||
$return->{$id}->{capacity} = "$record->{$id}->{int05}" || "1";
|
||||
|
||||
$return->{$id}->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{int04}";
|
||||
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
|
||||
$return->{$id}->{uri_operator} = "$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}";
|
||||
($return->{$id}->{gps}->{latitude},$return->{$id}->{gps}->{longitude}) = split(/,/,$record->{$id}->{txt06});
|
||||
my $description = $q->unescapeHTML($record->{$id}->{txt01}) || "";
|
||||
$return->{$id}->{description} = "$description";
|
||||
|
@ -2497,7 +2497,7 @@ sub stations_all(){
|
|||
}
|
||||
}
|
||||
|
||||
$return->{$id}->{uri_operator} = "$varenv->{wwwhost}";
|
||||
$return->{$id}->{uri_operator} = "$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}";
|
||||
($return->{$id}->{gps}->{latitude},$return->{$id}->{gps}->{longitude}) = split(/,/,$record->{$id}->{txt06});
|
||||
if($record->{$id}->{description}){
|
||||
my $description = $q->unescapeHTML($record->{$id}->{txt01}) || "";
|
||||
|
@ -2940,6 +2940,16 @@ sub auth_verify(){
|
|||
$update_primary->{txt26} = $q->escapeHTML($user_agent) if($user_agent);
|
||||
}
|
||||
|
||||
#check prepaid account
|
||||
if($auth_primary->{int03} == 3){
|
||||
my $prepaidhash = { prepaid_total => 0 };
|
||||
$prepaidhash = $pri->collect_prepaid($dbh_primary,$auth_primary) if($auth_primary->{c_id});
|
||||
if(!$prepaidhash->{prepaid_total} || $prepaidhash->{prepaid_total} < 0){
|
||||
my $vde = $auth_primary->{int12} || 1;
|
||||
$update_primary->{int12} = $vde;
|
||||
}
|
||||
}
|
||||
|
||||
my $rows = $dbt->update_record($dbh_primary,$update_primary,$auth_primary);
|
||||
$auth_primary = $dbt->fetch_record($dbh_primary,$authref);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ my $response = {
|
|||
apiserver => "$apiserver",
|
||||
response => "$respreq",
|
||||
uri_primary => "$dbt->{primary}->{sharee_primary}->{primaryApp}",
|
||||
copri_version => "4.1.23.22",
|
||||
copri_version => "4.1.23.23",
|
||||
user_id => "",
|
||||
authcookie => "",
|
||||
new_authcoo => "0",
|
||||
|
|
|
@ -171,6 +171,7 @@ sub handler {
|
|||
#update adr also on primary
|
||||
my $dbh_primary = $dbt->dbconnect($dbt->{primary}->{sharee_primary}->{database}->{dbname});
|
||||
$dbt->update_record($dbh_primary,$update_adr,$ctadr);
|
||||
print FILE Dumper($update_adr) . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,13 +47,17 @@ sub handler {
|
|||
my $debug=1;
|
||||
my $user_agent = $q->user_agent();
|
||||
my $dbh = "";
|
||||
|
||||
$bw->log("APIvelo POST:\n--> user-agent: '$user_agent' to syshost: $varenv{syshost}\n",$q,"");
|
||||
my %headers = map { $_ => $q->http($_) } $q->http();
|
||||
#$bw->log("APIvelo POST:\n--> user-agent: '$user_agent' to syshost: $varenv{syshost}\n",$q,"");
|
||||
|
||||
print $q->header(-type => "application/json", -charset => "utf-8", -'Access-Control-Allow-Origin' => "*");
|
||||
|
||||
open(FILE,">>$varenv{logdir}/APIvelo.log") if($debug);
|
||||
print FILE "\n*** $now_dt user-agent: '$user_agent' to syshost: $varenv{syshost}\n" if($debug);
|
||||
#print FILE "headers:" . Dumper(%headers) . "\n";
|
||||
for my $header ( keys %headers ) {
|
||||
print FILE "$header: $headers{$header}\n";
|
||||
}
|
||||
print FILE "<=== veloDUMP\n " . Dumper($q) . "\n" if($debug);
|
||||
print FILE "<=== DUMP postdata:\n " . Dumper($q->param('POSTDATA')) . "\n" if($debug);
|
||||
|
||||
|
@ -68,7 +72,7 @@ eval {
|
|||
#- int30=velofactur station ID
|
||||
#- int31=velofactur slot ID
|
||||
|
||||
my $jrout = $json->pretty->encode({ fakturjson => $response_in });
|
||||
my $jrout = $json->pretty->encode($response_in);
|
||||
print FILE "<=== JSON POST from velofactur:\n$jrout\n" if($debug);
|
||||
|
||||
my $record_cc = { c_id => 0 };
|
||||
|
@ -118,7 +122,7 @@ eval {
|
|||
#$update_cc->{int29} = 1;
|
||||
}
|
||||
|
||||
$rows = $dbt->update_record($dbh_operator,$update_cc,$record_cc);
|
||||
#$rows = $dbt->update_record($dbh_operator,$update_cc,$record_cc);
|
||||
$bw->log("velofactur updates dbname: $sharee_operator, c_id=$record_cc->{c_id} by fakturjson $response_in->{Typ} | rows:$rows",$update_cc,"");
|
||||
print FILE "---> velofactur updates dbname: $sharee_operator, c_id=$record_cc->{c_id} by fakturjson $response_in->{Typ} | rows:$rows\n" . Dumper($update_cc) . "\n" if($debug);
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ sub isuser_rentable {
|
|||
my $varenv = shift;
|
||||
|
||||
my $rentable_check=0;
|
||||
if($auth->{int03} && $auth->{ct_name} && ($auth->{int03} == 1 && $auth->{ct_name} =~ /\w{2}-\d+/) || ($auth->{int03} == 2 && length($auth->{ct_name}) >= 19) || ($auth->{int03} == 3 && $auth->{ct_name} =~ /Prepay-\d+/i)){
|
||||
if($auth->{int03} && $auth->{ct_name} && ($auth->{int03} == 1 && $auth->{ct_name} =~ /\w{2}-\d+/) || ($auth->{int03} == 2 && length($auth->{ct_name}) >= 19) || ($auth->{int03} == 3 && $auth->{ct_name} =~ /Prepaid-\d+/i)){
|
||||
$rentable_check=1;
|
||||
if($auth->{txt08} && $auth->{int04} == 1 && $auth->{int13} == 1 && !$auth->{int12} && $auth->{int14}){
|
||||
$rentable_check=2;#if 2 then everything should be alright. rental is enabled
|
||||
|
|
|
@ -429,27 +429,47 @@ sub collect_node {
|
|||
return ($nodes,$rows);
|
||||
}
|
||||
|
||||
#only used by dead_relation
|
||||
sub collect_relation {
|
||||
#collect main_ids
|
||||
sub collect_noderec {
|
||||
my $self = shift;
|
||||
my $dbh = shift || $dbh_intern;
|
||||
my $where = shift || "1=1";
|
||||
my $main_id = shift;
|
||||
|
||||
my $sth = $dbh->prepare("SELECT * FROM relation where $where");
|
||||
my $rc = $sth->execute();
|
||||
my $rel = $sth->fetchall_hashref("rel_id");
|
||||
return $rel;
|
||||
my $main_ids = "$main_id,";
|
||||
my ($main_collect,$rows) = $self->collect_node($dbh,$main_id);
|
||||
if(ref($main_collect) eq "HASH"){
|
||||
foreach my $id (keys (%$main_collect)){
|
||||
if($main_collect->{$id}->{node_name}){
|
||||
$main_ids .= "$main_collect->{$id}->{main_id},";
|
||||
my ($main_collect2,$rows) = $self->collect_node($dbh,$main_collect->{$id}->{main_id}) if($main_collect->{$id}->{main_id});
|
||||
if(ref($main_collect2) eq "HASH"){
|
||||
foreach my $id (keys (%$main_collect2)){
|
||||
$main_ids .= "$main_collect2->{$id}->{main_id},";
|
||||
my ($main_collect3,$rows) = $self->collect_node($dbh,$main_collect2->{$id}->{main_id}) if($main_collect2->{$id}->{main_id});
|
||||
if(ref($main_collect3) eq "HASH"){
|
||||
foreach my $id (keys (%$main_collect3)){
|
||||
$main_ids .= "$main_collect3->{$id}->{main_id},";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$main_ids =~ s/,$//;
|
||||
return $main_ids;
|
||||
}
|
||||
|
||||
#not used
|
||||
sub collect_relct {
|
||||
#collect relation nodes
|
||||
sub collect_rel4nodes(){
|
||||
my $self = shift;
|
||||
my $dbh = shift || $dbh_intern;
|
||||
my $ref = shift;
|
||||
my $sth = $dbh->prepare("SELECT * FROM relation rel, $ref->{table} c where rel.content_id > 0 and rel.template_id=224 and rel.content_id=c.c_id order by rel.content_id");
|
||||
my $main_ids = shift;
|
||||
|
||||
my $sth = $dbh->prepare("SELECT * FROM relation rel, nodes nd where rel.main_id=nd.main_id and parent_id IN ($main_ids)");
|
||||
my $rc = $sth->execute();
|
||||
my $rel = $sth->fetchall_hashref("rel_id");
|
||||
return $rel;
|
||||
my $rel4nd = $sth->fetchall_hashref("rel_id");
|
||||
return $rel4nd;
|
||||
}
|
||||
|
||||
# Nodes einer Ebene mit relation
|
||||
|
@ -582,21 +602,6 @@ sub fetch_rel4tpl4nd(){
|
|||
return $rel;
|
||||
}
|
||||
|
||||
#azn time worktime from Von Bis
|
||||
sub select_worktime {
|
||||
my $self = shift;
|
||||
my $dbh = shift || $dbh_intern;
|
||||
my $fetch = shift;
|
||||
|
||||
my $sql = "SELECT $fetch->{end_at} - $fetch->{start_at} AS worktime FROM $fetch->{table} where ct_id = $fetch->{ct_id} and barcode = $fetch->{barcode} and $fetch->{end_at} is not null and $fetch->{start_at} is not null";
|
||||
my $sth = $dbh->prepare($sql);
|
||||
my $rc = $sth->execute();
|
||||
my $record = $sth->fetchrow_hashref();
|
||||
$bw->log("DBtank select_worktime: ",$sql,"") if($debug);
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
#all accounting position of contenttrans
|
||||
sub collect_contenttrans(){
|
||||
my $self = shift;
|
||||
|
@ -1190,6 +1195,28 @@ sub delete_content(){
|
|||
return $rows;
|
||||
}
|
||||
|
||||
#collect content with contenttranspos
|
||||
sub collect_postime(){
|
||||
my $self = shift;
|
||||
my $dbh = shift || $dbh_intern;
|
||||
my $table = shift;
|
||||
my $start_date_time = shift;
|
||||
my $end_date_time = shift;
|
||||
my $start_date2 = shift || "";
|
||||
my $end_date2 = shift || "";
|
||||
|
||||
$start_date_time =~ s/,/./g;
|
||||
$end_date_time =~ s/,/./g;
|
||||
my $where = "where cp.cc_id=c.c_id";
|
||||
$where .= " and cp.start_time >= $start_date_time";
|
||||
$where .= " and cp.end_time <= $end_date_time";
|
||||
$where .= " and (cp.start_time >= '$start_date2' OR cp.end_time >= '$start_date2')" if($start_date2 && $end_date2);
|
||||
my $sth = $dbh->prepare("SELECT cp.* from content c, $table cp $where order by cp.end_time");
|
||||
my $rc = $sth->execute();
|
||||
my $ct = $sth->fetchall_hashref("cc_id");
|
||||
return $ct;
|
||||
}
|
||||
|
||||
|
||||
#collect contenttranspos with contenttrans
|
||||
sub collect_transpos {
|
||||
|
@ -1563,7 +1590,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,int01,int02,int03,int06,txt05,txt06,txt07,int10,int12,template_id,int13,owner,int07,txt04,int09,int17,int15,int11,int18,int19,txt17,txt18,int20,int25,int29,int34,txt22,txt11,int35,int36,int37,int42,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','1','$unit_price','$menge','$start_station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$from_template_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$daymax_price','$abo_price','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','1','$trackon','$bike_type_id','$staff','$sig_book->{bikeId}','$sig_book->{rentalId}','$unit_price1','$unit_price2','$start_price','$aa_station','$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,int01,int02,int03,txt01,int10,int12,int16,template_id,owner) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$user_name','$ctadr->{txt09}',now(),'1','$unit_price','1','$ct->{txt01}','0','$from_main_id','$fibumark','$from_template_id','$owner') RETURNING c_id");
|
||||
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt08,itime,int01,int02,int03,txt01,int10,int12,int16,template_id,owner) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$user_name',now(),'1','$unit_price','1','$ct->{txt01}','0','$from_main_id','$fibumark','$from_template_id','$owner') RETURNING c_id");
|
||||
}
|
||||
my $rows = $sth->execute();
|
||||
my $last_id;
|
||||
|
@ -1675,7 +1702,7 @@ sub evaluationsfragen {
|
|||
}
|
||||
|
||||
#search table content.
|
||||
sub search_content(){
|
||||
sub search_content {
|
||||
my $self = shift;
|
||||
my $dbh = shift || $dbh_intern;
|
||||
my $searchref = shift;
|
||||
|
@ -1683,14 +1710,12 @@ sub search_content(){
|
|||
my $users_dms = shift;
|
||||
my $main_ids = shift || 0;
|
||||
my $tplids = shift || 0;
|
||||
my $ct_ids = shift || 0;
|
||||
my $v_journal = shift || "";
|
||||
my $ck4ex = shift || "";
|
||||
|
||||
my $table = $node_meta->{ct_table};
|
||||
$main_ids =~ s/,$//;
|
||||
$tplids =~ s/,$//;
|
||||
$ct_ids =~ s/,$//;
|
||||
$ck4ex =~ s/\s/,/g;
|
||||
$ck4ex =~ s/,$//;
|
||||
|
||||
|
@ -1706,12 +1731,11 @@ sub search_content(){
|
|||
my $debug=0;
|
||||
$debug=1;
|
||||
open(FILE,">>$varenv{logdir}/Liste3.log") if($debug);
|
||||
print FILE "*** $stamp_time Libenzdb.search_content3 ***\n" if($debug);
|
||||
print FILE "*** $stamp_time search_content3 ***\n" if($debug);
|
||||
print FILE Dumper($searchref) if($debug);
|
||||
print FILE "$table,$node_meta->{node_name},$owner,$sort_updown,$main_ids,$tplids,$ct_ids,$v_journal,$ck4ex\n" if($debug);
|
||||
print FILE "$table,$node_meta->{node_name},$owner,$sort_updown,$main_ids,$tplids,$v_journal,$ck4ex\n" if($debug);
|
||||
close(FILE) if($debug);
|
||||
|
||||
|
||||
my $table_pos = $searchref->{table_pos} || "";
|
||||
my $txt_where;
|
||||
my $cptxt_where;
|
||||
|
@ -1726,23 +1750,22 @@ sub search_content(){
|
|||
$opref->{$key} = "=";
|
||||
($opref->{$key}, $valref->{$key}) = split(/::/, $searchref->{$key}) if($searchref->{$key} =~ /::/);
|
||||
if($key =~ /table_pos/){
|
||||
$table_pos = $valref->{$key};
|
||||
$table_pos = $valref->{$key};
|
||||
}
|
||||
if($key =~ /c_id|int\d+|barcode|time|sort|owner/){
|
||||
$searchref->{$key} =~ s/,/./g;
|
||||
if($searchref->{$key} =~ /(\<\=|\>\=|\<|\>|\=)/){
|
||||
$opref->{$key} = $1;
|
||||
$opref->{$key} = $1;
|
||||
}
|
||||
if($searchref->{$key} =~ /([-0-9\.]+)/){
|
||||
$valref->{$key} = $1;
|
||||
$valref->{$key} = $1;
|
||||
}
|
||||
if($searchref->{$key} =~ /null/){
|
||||
$opref->{$key} = "is";
|
||||
$opref->{$key} = "is";
|
||||
}
|
||||
chomp($valref->{$key});
|
||||
}
|
||||
$valref->{$key} = $q->escapeHTML($valref->{$key});
|
||||
#print $key . ":" . $opref->{$key} . ":" . $valref->{$key} . "\n";
|
||||
|
||||
if($table_pos =~ /contentpos|contentadrpos|users/){
|
||||
if($key =~ /ct_name/){
|
||||
|
@ -1756,46 +1779,36 @@ sub search_content(){
|
|||
if($key eq "ct_name" && $valref->{$key} =~ /^\d+$/){
|
||||
$txt_where .= " and (ct.$key ilike '$valref->{$key}' OR ct.barcode $opref->{$key} $valref->{$key})";
|
||||
}elsif($key eq "ct_name"){
|
||||
$txt_where .= " and ct.$key ilike '$valref->{$key}%'";
|
||||
$txt_where .= " and ct.$key ilike '$valref->{$key}%'";
|
||||
}elsif($key =~ /_id|barcode|int\d+|sort|owner/ && (looks_like_number($valref->{$key}) || $valref->{$key} =~ /null|0/)){
|
||||
$txt_where .= " and ct.$key $opref->{$key} $valref->{$key}";
|
||||
}elsif($key =~ /txt|uri/){
|
||||
$txt_where .= " and ct.$key ilike '%$valref->{$key}%'";
|
||||
}elsif($key eq "state"){
|
||||
#searchs also order_state
|
||||
$txt_where .= " and (ct.state ilike '%$valref->{$key}%' OR ct.txt22 ilike '%$valref->{$key}%')";
|
||||
$txt_where .= " and (ct.state ilike '%$valref->{$key}%' OR ct.txt22 ilike '%$valref->{$key}%')";
|
||||
}elsif($key =~ /byte/){
|
||||
$txt_where .= " and ct.$key = '\\x$valref->{$key}'";
|
||||
}
|
||||
|
||||
#sum pos doesn't work anymore
|
||||
#if($key =~ /int01/ && $table eq "contenttrans" && looks_like_number($valref->{$key})){
|
||||
#$cpgroup_where .= " group by cp.ct_id HAVING sum(cp.int02) $opref->{$key} $valref->{$key}";
|
||||
#}
|
||||
}
|
||||
|
||||
#if($key =~ /end_/ && $key =~ /time$/){
|
||||
#$valref->{$key} .= " 23:59" if($valref->{$key} !~ /\d:\d/);
|
||||
#}
|
||||
|
||||
|
||||
if(!$v_journal){
|
||||
if($table_pos =~ /contentpos|contentadrpos|users/ && $key =~ /mtime/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
|
||||
$cptxt_where .= " and cp.mtime >= '$valref->{$key}'" if($key =~ /start/);
|
||||
$cptxt_where .= " and cp.mtime < '$valref->{$key}'" if($key =~ /end/);
|
||||
$cptxt_where .= " and cp.mtime >= '$valref->{$key}'" if($key =~ /start/);
|
||||
$cptxt_where .= " and cp.mtime < '$valref->{$key}'" if($key =~ /end/);
|
||||
}
|
||||
elsif($table_pos =~ /contentpos|contentadrpos|users/ && $key eq "template_id_pos" && $valref->{$key}){
|
||||
$cptxt_where .= " and cp.template_id = $valref->{$key}";
|
||||
$cptxt_where .= " and cp.template_id = $valref->{$key}";
|
||||
}
|
||||
elsif($key =~ /mtime/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
|
||||
$txt_where .= " and ct.mtime >= '$valref->{$key}'" if($key =~ /start/);
|
||||
$txt_where .= " and ct.mtime < '$valref->{$key}'" if($key =~ /end/);
|
||||
$txt_where .= " and ct.mtime >= '$valref->{$key}'" if($key =~ /start/);
|
||||
$txt_where .= " and ct.mtime < '$valref->{$key}'" if($key =~ /end/);
|
||||
}
|
||||
|
||||
}elsif($v_journal){
|
||||
if($key =~ /itime/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
|
||||
$txt_where .= " and ct.itime >= '$valref->{$key}'" if($key =~ /start/);
|
||||
$txt_where .= " and ct.itime < '$valref->{$key}'" if($key =~ /end/);
|
||||
$txt_where .= " and ct.itime >= '$valref->{$key}'" if($key =~ /start/);
|
||||
$txt_where .= " and ct.itime < '$valref->{$key}'" if($key =~ /end/);
|
||||
}
|
||||
if($key =~ /start_mtime/ && $valref->{$key} =~ /^\d+$/){
|
||||
$txt_where .= " and ct.int11 = '$valref->{$key}'";#int11 = c_id-abschluss key
|
||||
|
@ -1822,7 +1835,6 @@ sub search_content(){
|
|||
}
|
||||
}
|
||||
}#
|
||||
|
||||
if($v_journal =~ /Tagesbericht/){
|
||||
$txt_where .= " and (ct.state ~ '[a-z]') and ct.int01 is not null and ct.close_time is null";
|
||||
$txt_where .= " and ct.int14 is $opos" if($opos eq "null");
|
||||
|
@ -1838,10 +1850,6 @@ sub search_content(){
|
|||
$sth = $dbh->prepare("SELECT cp.* FROM contenttranspos cp WHERE cp.ct_id IN (SELECT ct.c_id FROM relation rel, contenttrans ct WHERE rel.content_id=ct.c_id and rel.main_id IN ($main_ids) and rel.template_id IN ($tplids) $txt_where) $cptxt_where ORDER BY cp.$cp_scol $updown");
|
||||
}elsif($valref->{long_rent} || $valref->{start_date_time} =~ /^\d+\.\d+\.\d+/ || $valref->{end_date_time} =~ /^\d+\.\d+\.\d+/ || $cpgroup_where){
|
||||
$sth = $dbh->prepare("SELECT * FROM relation rel, $table ct WHERE rel.content_id=ct.c_id and rel.main_id IN ($main_ids) and rel.template_id IN ($tplids) $txt_where and c_id IN (SELECT cp.ct_id from contenttranspos cp WHERE 1=1 $cptxt_where $cpgroup_where) ORDER BY $scol $updown LIMIT $limit OFFSET $offset");
|
||||
}elsif($v_journal && $ct_ids){#and executes ct_ids
|
||||
$ct_ids = 0 if(!$ct_ids);
|
||||
$sth = $dbh->prepare("SELECT * FROM relation rel, $table ct WHERE rel.content_id=ct.c_id and rel.main_id IN ($main_ids) and rel.template_id IN ($tplids) and rel.content_id IN ($ct_ids) $txt_where ORDER BY $scol $updown LIMIT $limit OFFSET $offset");
|
||||
|
||||
}elsif($table_pos && $table_pos eq "contentpos"){
|
||||
$sth = $dbh->prepare("SELECT cp.* FROM contentpos cp WHERE cp.cc_id IN (SELECT ct.c_id FROM relation rel, content ct WHERE rel.content_id=ct.c_id and rel.main_id IN ($main_ids) and rel.template_id IN ($tplids) $txt_where) $cptxt_where ORDER BY cp.$scol $updown LIMIT $limit OFFSET $offset");
|
||||
}elsif($table_pos && $table_pos eq "contentadrpos"){
|
||||
|
@ -1856,7 +1864,6 @@ sub search_content(){
|
|||
}else{
|
||||
$sth = $dbh->prepare("SELECT * FROM relation rel, $table ct WHERE rel.content_id=ct.c_id and rel.main_id IN ($main_ids) and rel.template_id IN ($tplids) $txt_where ORDER BY $scol $updown LIMIT $limit OFFSET $offset");
|
||||
}
|
||||
|
||||
my $rc = $sth->execute();
|
||||
my $s_id = "c_id";
|
||||
$s_id = "u_id" if($table_pos && $table_pos eq "users");
|
||||
|
|
|
@ -38,7 +38,7 @@ sub handler {
|
|||
my $cf = new Config;
|
||||
my $ml = new Mlogic;
|
||||
my $bw = new Basework;
|
||||
my $tk = new Shareework;
|
||||
my $shwo = new Shareework;
|
||||
my $dbt = new DBtank;
|
||||
my $apif = new APIfunc;
|
||||
my $but = new Buttons;
|
||||
|
@ -195,8 +195,8 @@ sub handler {
|
|||
$apif->authout($q,$coo);
|
||||
|
||||
#create_account. 2. inserts contentadr
|
||||
my $tinkc_id = $tk->create_account($aowner);
|
||||
($returnwww,$feedb) = $tk->save_account($q,$tinkc_id,\%varenv,$aowner);
|
||||
my $shareec_id = $shwo->create_account($aowner);
|
||||
($returnwww,$feedb) = $shwo->save_account($q,$shareec_id,\%varenv,$aowner);
|
||||
|
||||
#Like login_sharee, redundant
|
||||
my $hw_id = unpack ('H*', pack('Nc', time, $$ % 0xff));#old $co
|
||||
|
@ -218,8 +218,8 @@ sub handler {
|
|||
|
||||
#if user-pw authorized, then ignore conflict_ because it matches exist user-data
|
||||
#should be result to Uhps page
|
||||
if($tinkc_id && $returnwww && $returnwww =~ /conflict_txt07|conflict_txt08/){
|
||||
$return = $tk->delete_account($tinkc_id,$users_dms->{u_id});
|
||||
if($shareec_id && $returnwww && $returnwww =~ /conflict_txt07|conflict_txt08/){
|
||||
$return = $shwo->delete_account($shareec_id,$users_dms->{u_id});
|
||||
$apif->authout($q,$coo) if($coo);
|
||||
print redirect("$varenv{wwwhost}/$varenv{mandant}/Anmelden?conflict_failure=1");
|
||||
exit 0;
|
||||
|
@ -353,9 +353,9 @@ sub handler {
|
|||
my $delete_key = "delete_adr";
|
||||
$feedb->{message} = "failure::Datensatz wirklich löschen. ::?base_edit=$delete_key\&exit_box2=1\&c_id=$R::c_id ::löschen";
|
||||
}elsif($R::c_id && $R::base_edit eq "delete_adr"){
|
||||
$return = $tk->delete_account($R::c_id,$users_dms->{u_id});
|
||||
$return = $shwo->delete_account($R::c_id,$users_dms->{u_id});
|
||||
}elsif($R::c_id && $R::base_edit eq "save_adr"){
|
||||
($returnwww,$feedb) = $tk->save_account($q,$R::c_id,\%varenv,$users_dms->{u_id});
|
||||
($returnwww,$feedb) = $shwo->save_account($q,$R::c_id,\%varenv,$users_dms->{u_id});
|
||||
}
|
||||
}else{
|
||||
$feedb->{message} = "failure::Abbruch. Schreibender Zugriff \"Kunden Stammdaten\" verweigert.";
|
||||
|
@ -540,12 +540,15 @@ sub handler {
|
|||
|
||||
#save_account. 3. updates contentadr
|
||||
if($users_sharee->{c_id} && $R::sharee_edit && $R::sharee_edit =~ /save_account/){
|
||||
($returnwww,$feedb) = $tk->save_account($q,$users_sharee->{c_id},\%varenv,$aowner);
|
||||
($returnwww,$feedb) = $shwo->save_account($q,$users_sharee->{c_id},\%varenv,$aowner);
|
||||
}
|
||||
|
||||
if($users_sharee->{c_id} && $R::sharee_edit && $R::sharee_edit =~ /save_transact/){
|
||||
$returnwww = $tk->save_transact($q,$users_sharee->{c_id},$coo,$aowner);
|
||||
$returnwww = $shwo->save_transact($q,$users_sharee->{c_id},$coo,$aowner);
|
||||
}
|
||||
#we do it in PayoneLink.pm
|
||||
#if($users_sharee->{c_id} && $R::sharee_edit && $R::sharee_edit =~ /generate_payonelink/){
|
||||
# $returnwww = $pay->generate_payonelink($q,\%varenv,$users_sharee,$R::prepaid_id,$R::prepaid_amount,$aowner);
|
||||
#}
|
||||
|
||||
if($returnwww && $returnwww =~ /failure::(.*)/){
|
||||
$returnwww =~ s/::/=/g;
|
||||
|
@ -554,10 +557,8 @@ sub handler {
|
|||
if($returnwww =~ /txt22|txt23/){
|
||||
#should be result to Uhps page
|
||||
if($returnwww =~ /conflict_txt22/){
|
||||
$return = $tk->delete_account($users_sharee->{c_id},$users_dms->{u_id});
|
||||
$apif->authout($q,$coo) if($coo);
|
||||
print redirect("$varenv{wwwhost}/$varenv{mandant}/Anmelden?conflict_failure=1$session_and");
|
||||
exit 0;
|
||||
print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_2}?cum=1\&conflict_failure=1$session_and\&$returnwww");
|
||||
exit 0;
|
||||
}
|
||||
print redirect("$varenv{wwwhost}/$varenv{mandant}/Account/$varenv{accounting_2}?cum=1$session_and\&$returnwww");
|
||||
}elsif($returnwww =~ /int03/){
|
||||
|
@ -586,7 +587,6 @@ sub handler {
|
|||
print FILE "$_=$val\n";
|
||||
$payone_return .= "$_=$val\n";# if($_ =~ /error|message/i);
|
||||
}
|
||||
close(FILE);
|
||||
|
||||
my $update_adr = {
|
||||
table => "contentadr",
|
||||
|
@ -637,10 +637,10 @@ sub handler {
|
|||
#int12=0 should be set after capture success in payment module
|
||||
|
||||
if(($users_sharee->{int04} != 1) && ($users_sharee->{txt08} =~ /\w\@\w/)){
|
||||
$tk->emailack(\%varenv,$users_sharee->{c_id});
|
||||
$shwo->emailack(\%varenv,$users_sharee->{c_id});
|
||||
}
|
||||
if(($users_sharee->{int13} != 1) && ($users_sharee->{txt07} =~ /\d{9}/ && length($users_sharee->{txt07}) <= 16)){
|
||||
$tk->smsack($users_sharee);
|
||||
$shwo->smsack($users_sharee);
|
||||
}
|
||||
close(FILE) if($debug);
|
||||
}else{
|
||||
|
@ -657,6 +657,9 @@ sub handler {
|
|||
$dbt->update_record($dbh,$update_adr,$users_sharee) if($users_sharee->{c_id} > 0);
|
||||
$dbt->update_operatorsloop($varenv{dbname},$users_sharee->{c_id},"update");
|
||||
}
|
||||
|
||||
print FILE Dumper($update_adr) . "\n" if($debug);
|
||||
close(FILE);
|
||||
}#end payone response with pseudocardpan
|
||||
}
|
||||
|
||||
|
@ -668,10 +671,10 @@ sub handler {
|
|||
print FILE "trigger confirm-code request by $R::sharee_edit\n" if($debug);
|
||||
|
||||
if(($users_sharee->{int04} != 1 && $R::sharee_edit =~ /send_email/) && ($users_sharee->{txt08} =~ /\w\@\w/)){
|
||||
$tk->emailack(\%varenv,$users_sharee->{c_id});
|
||||
$shwo->emailack(\%varenv,$users_sharee->{c_id});
|
||||
}
|
||||
if(($users_sharee->{int13} != 1 && $R::sharee_edit =~ /send_sms/) && ($users_sharee->{txt07} =~ /\d{9}/ && length($users_sharee->{txt07}) <= 16)){
|
||||
$tk->smsack($users_sharee);
|
||||
$shwo->smsack($users_sharee);
|
||||
}
|
||||
close(FILE) if($debug);
|
||||
}#send confirm code
|
||||
|
@ -771,7 +774,7 @@ sub handler {
|
|||
|
||||
if($R::email && $R::sharee_edit =~ /password_forgotten/){
|
||||
my $hw_id = unpack ('H*', pack('Nc', time, $$ % 0xff));#old $co
|
||||
$tk->send_password(\%varenv,$R::email,$hw_id,$aowner);
|
||||
$shwo->send_password(\%varenv,$R::email,$hw_id,$aowner);
|
||||
}
|
||||
|
||||
#redirections
|
||||
|
|
|
@ -18,7 +18,6 @@ use CGI::Carp qw(fatalsToBrowser);
|
|||
use Calendar::Simple;
|
||||
use Date::Calc qw(:all);
|
||||
use Mod::Callib;
|
||||
use Mod::Libenzdb;
|
||||
use Mod::Buttons;
|
||||
use Lib::Config;
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
|
@ -26,7 +25,6 @@ use Scalar::Util qw(looks_like_number);
|
|||
my $cf = new Config;
|
||||
my $cb = new Callib;
|
||||
my $but = new Buttons;
|
||||
my $db = new Libenzdb;
|
||||
my $q = new CGI;
|
||||
|
||||
#my $pi = new Image::Magick;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -13,7 +13,6 @@ use CGI::Carp qw(fatalsToBrowser);
|
|||
use Scalar::Util qw(looks_like_number);
|
||||
use Lib::Config;
|
||||
use Mod::Buttons;
|
||||
use Mod::Libenzdb;
|
||||
use Mod::DBtank;
|
||||
|
||||
sub new {
|
||||
|
@ -32,7 +31,6 @@ sub mobox(){
|
|||
my $q = new CGI;
|
||||
my $cf = new Config;
|
||||
my $but = new Buttons;
|
||||
my $db = new Libenzdb;
|
||||
my $dbt = new DBtank;
|
||||
$q->import_names('R');
|
||||
my @keywords = $q->param;
|
||||
|
|
|
@ -3,20 +3,19 @@ package Payment;
|
|||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
|
||||
#
|
||||
#Adapted from Prelogic Rechnung "buchen" and "print_pdf"
|
||||
#Adapted from payone_post.pl
|
||||
#
|
||||
#enable for syntax check
|
||||
#use lib "/var/www/copri-bike/shareedms-primary/src";
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use POSIX;
|
||||
use CGI; # only for debugging
|
||||
use CGI;
|
||||
use Digest::SHA qw(hmac_sha256_base64);
|
||||
use JSON;
|
||||
my $json = JSON->new->allow_nonref;
|
||||
use LWP::UserAgent;
|
||||
use URI::Encode;
|
||||
my $uri_encode = URI::Encode->new( { encode_reserved => 1 } );
|
||||
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
use Lib::Config;
|
||||
use Mod::Callib;
|
||||
|
@ -921,7 +920,6 @@ sub rpc {
|
|||
}
|
||||
print FILE "payone RPC end\n\n" if($debug);
|
||||
|
||||
close(FILE) if($debug);
|
||||
#set contentadr owner and mtime only if vde or payone-return will be set by payone id's
|
||||
if((($update_adr->{int12} && $update_adr->{int12} > 0) || $update_adr->{txt28}) && ($owner == 178 || $owner == 179)){
|
||||
$update_adr->{owner} = "$owner";
|
||||
|
@ -930,12 +928,15 @@ sub rpc {
|
|||
|
||||
if($ctadr->{c_id} > 0){
|
||||
$dbt->update_record($dbh,$update_adr,$ctadr);
|
||||
print FILE Dumper($update_adr) . "\n" if($debug);
|
||||
#2023-04-11 set it global by update adr also on primary
|
||||
#disabled, because isuser_rentable will be only used by operator rental
|
||||
#my $dbh_primary = $dbt->dbconnect($dbt->{primary}->{sharee_primary}->{database}->{dbname});
|
||||
#$dbt->update_record($dbh_primary,$update_adr,$ctadr);
|
||||
}
|
||||
$dbt->update_record($dbh,$update_ctt,$ctt) if($ctt->{c_id} > 0);
|
||||
|
||||
close(FILE) if($debug);
|
||||
return $payoneret;
|
||||
}
|
||||
|
||||
|
@ -1020,23 +1021,12 @@ sub payone_capture {
|
|||
return $return_text;
|
||||
}
|
||||
|
||||
my $state = $ctt->{state};
|
||||
if($dbt->{shareedms_conf}->{payment_state}){
|
||||
my @_paymentstate = split(/\|/,$dbt->{shareedms_conf}->{payment_state});
|
||||
if($ctadr->{ct_name} =~ /\w{2}-\d+/){
|
||||
$state = "$_paymentstate[0]";
|
||||
}else{
|
||||
undef $_paymentstate[0];
|
||||
}
|
||||
if(length($ctadr->{ct_name}) >= 19){
|
||||
$state = "$_paymentstate[1]";
|
||||
}else{
|
||||
undef $_paymentstate[1];
|
||||
}
|
||||
}
|
||||
|
||||
my $state = $ctt->{state} || "";
|
||||
my $p_hash = $dbt->{shareedms_conf}->{payment_state2};
|
||||
$state = $p_hash->{1} if($ctadr->{ct_name} =~ /\w{2}-\d+/);
|
||||
$state = $p_hash->{2} if(length($ctadr->{ct_name}) >= 19);
|
||||
$update_ctt->{state} = "$state";
|
||||
$dbt->update_record($dbh,$update_ctt,$ctt);
|
||||
$dbt->update_record($dbh,$update_ctt,$ctt) if($update_ctt->{state});
|
||||
|
||||
#in cron we set OPOS anyway. If payone captured, it will be set int14=null
|
||||
if(!$state || $state !~ /payone/){
|
||||
|
@ -1101,6 +1091,138 @@ sub payone_capture {
|
|||
return ($retval,$return_text);
|
||||
}
|
||||
|
||||
#Request "payone-link"
|
||||
sub generate_payonelink {
|
||||
my $self = shift;
|
||||
my $varenv = shift;
|
||||
my $ctadr = shift;
|
||||
my $prepaidhash = shift || {};
|
||||
my $prepaid_amount = shift || 0;
|
||||
my $owner = shift || 0;
|
||||
|
||||
my $payonelink_conf = $dbt->{payonelink_conf} || {};
|
||||
my $ret_json = {};
|
||||
my $response_in = {};
|
||||
my $dbh = "";
|
||||
|
||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||
open(FILE,">>$varenv->{logdir}/payonelink.log");
|
||||
print FILE "\n*** $now_dt 'generate_payonelink' ctadr:$ctadr->{c_id}|$ctadr->{txt08}\n";
|
||||
|
||||
my $prepaid_amount2 = 0;
|
||||
$prepaid_amount2 = $1 if($prepaid_amount =~ /^(\d+)/);
|
||||
|
||||
if($ctadr->{c_id} && $prepaidhash->{prepaid_id} && $prepaid_amount2 >= 5){
|
||||
|
||||
my $lastname = $ctadr->{txt01};
|
||||
(my $firstname,$lastname) = split(/\s+/,$ctadr->{txt01}) if($ctadr->{txt01} =~ /\w\s+\w/i);
|
||||
chomp($firstname);
|
||||
chomp($lastname);
|
||||
my $city = $ctadr->{txt06};
|
||||
(my $zip, $city) = split(/\s+/,$ctadr->{txt06}) if($ctadr->{txt06} =~ /[\w\d]\s+[\w\d]/i);
|
||||
chomp($zip);
|
||||
chomp($city);
|
||||
|
||||
my $currency = "EUR";
|
||||
my $amount = 0;
|
||||
$amount = $prepaid_amount2 * 100 if($prepaid_amount2);
|
||||
my $pay_request = {
|
||||
intent => 'authorization',
|
||||
active => 1,
|
||||
paymentMethods => ['visa', 'mastercard', 'paypal', 'sofort', 'paydirekt', 'giropay', 'sepa'],
|
||||
userId => "$ctadr->{c_id}",
|
||||
email => "$ctadr->{txt08}",
|
||||
firstName => "$firstname",
|
||||
lastName => "$lastname",
|
||||
country => "$ctadr->{txt10}",
|
||||
language => "de_DE",
|
||||
reference => "$prepaidhash->{prepaid_id}",
|
||||
shoppingCart => [{
|
||||
type => "prepaid",
|
||||
number => "$prepaidhash->{number}",
|
||||
price => $amount,
|
||||
quantity => 1,
|
||||
description => "$prepaidhash->{description}",
|
||||
vatRate => 19
|
||||
}]
|
||||
};
|
||||
|
||||
|
||||
my $datahash = $payonelink_conf->{merchantId} . $payonelink_conf->{accountId} . $payonelink_conf->{portalId} . $payonelink_conf->{mode} . $prepaidhash->{prepaid_id} . $amount . $currency;
|
||||
|
||||
my $paytoken = hmac_sha256_base64($datahash, $payonelink_conf->{portalKey});
|
||||
|
||||
#my $whole_json = { %$payonelink_conf, %$pay_request};
|
||||
#my $rest_json = encode_json($whole_json);
|
||||
my $rest_json = encode_json(\%{ $pay_request });
|
||||
|
||||
print FILE "rest_json:\n" . Dumper($rest_json) . "\n";
|
||||
|
||||
($ret_json, my $ret_status) = $self->rpc_postjson($paytoken,$rest_json);
|
||||
eval {
|
||||
$response_in = decode_json($ret_json);
|
||||
print FILE "<--- payonelink response_in with status_line: $ret_status\n" . Dumper($response_in);
|
||||
print FILE $ret_json . "\n";
|
||||
|
||||
#expecting something like this:
|
||||
#return "https://onelink.pay1.de/p/YNEVNS4N1N5JXTFLYPMQJ5PVADEEZ0UL?lang=de_DE";
|
||||
};
|
||||
if ($@){
|
||||
print FILE "<--- failure payonelink raw response_in with status_line: $ret_status\n" . Dumper($ret_json) . "\n";
|
||||
#warn $@;
|
||||
print FILE "warn:" . $@ . "\n";
|
||||
}
|
||||
|
||||
}else{
|
||||
$ret_json = "failure:: $ctadr->{c_id} && $prepaidhash->{prepaid_id} && $prepaid_amount2 >= 5";
|
||||
}
|
||||
|
||||
close FILE;
|
||||
return $ret_json;
|
||||
}#end Request "send_payone_link"
|
||||
|
||||
#JSON POST to onelink
|
||||
sub rpc_postjson {
|
||||
my $self = shift;
|
||||
my $paytoken = shift;
|
||||
my $rest_json = shift || "";
|
||||
|
||||
my $api_file = "/var/www/copri4/shareeconf/apikeys.cfg";
|
||||
my $aconf = Config::General->new($api_file);
|
||||
my %apikeyconf = $aconf->getall;
|
||||
|
||||
my $ua = LWP::UserAgent->new(
|
||||
ssl_opts => {
|
||||
SSL_version => 'TLSv12:!SSLv2:!SSLv3:!TLSv1:!TLSv11',
|
||||
}
|
||||
);
|
||||
|
||||
$ua->agent("sharee payone jsonPOST API");
|
||||
my $bytes = 100000;
|
||||
$ua->max_size( $bytes );
|
||||
$ua->default_header( 'Authorization' => "payone-hmac-sha256 $paytoken" );
|
||||
print Dumper($ua);
|
||||
|
||||
#local TEST
|
||||
my $endpoint = "https://shareeapp-fr01.copri-bike.de/APIvelo";
|
||||
#my $endpoint = "https://onelink.pay1.de/api/v1/payment-links/";
|
||||
|
||||
my $req = HTTP::Request->new(POST => "$endpoint");
|
||||
$req->content_type('application/json');
|
||||
$req->content($rest_json);
|
||||
my $res = $ua->request($req);
|
||||
|
||||
if ($res->is_success) {
|
||||
#print $res->content;
|
||||
#print $res->status_line, "\n";
|
||||
return ($res->content, $res->status_line);
|
||||
}else {
|
||||
#print $res->status_line, "\n";
|
||||
return ("", $res->status_line);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ my $debug=1;
|
|||
sub prepaid_request {
|
||||
my $self = shift;
|
||||
my $dbh = shift;
|
||||
my $ctadr = shift;
|
||||
my $ctadr = shift || {};
|
||||
my $owner = shift;
|
||||
|
||||
my $feedb = {
|
||||
|
@ -61,6 +61,7 @@ sub prepaid_request {
|
|||
message => "",
|
||||
};
|
||||
|
||||
if($ctadr->{c_id}){
|
||||
my $pref_ctt = {
|
||||
table => "contenttrans",
|
||||
fetch => "one",
|
||||
|
@ -76,6 +77,13 @@ sub prepaid_request {
|
|||
my $ct_id = $dbt->insert_contenttrans($dbh,$ctadr,"300023","219","----","$owner");
|
||||
$pref_ctt->{c_id} = $ct_id;
|
||||
$ctt_prepaid = $dbt->fetch_record($dbh,$pref_ctt) if($pref_ctt->{c_id});
|
||||
my $update_adr = {
|
||||
table => "contentadr",
|
||||
mtime => "now()",
|
||||
owner => "$owner",
|
||||
c_id => "$ctadr->{c_id}",
|
||||
};
|
||||
$dbt->update_one($dbh,$update_adr,"ct_name='Prepaid-$ctt_prepaid->{c_id}'");
|
||||
}
|
||||
|
||||
my $pos_id = 0;
|
||||
|
@ -107,13 +115,14 @@ sub prepaid_request {
|
|||
|
||||
$cttpos->{c_id} = $dbt->insert_pos($dbh,$ctt_prepaid->{c_id},$ct,"",$ctadr,"","","","0",$owner,"");
|
||||
$dbt->update_one($dbh,{table => 'contenttranspos',c_id => $cttpos->{c_id}},"barcode = $cttpos->{c_id},ct_name = '$cttpos->{c_id}'");
|
||||
$feedb->{prepaid_id} = $ctt_prepaid->{c_id} . "-" . $cttpos->{c_id};
|
||||
}
|
||||
}
|
||||
|
||||
$feedb->{prepaid_account} = $ctt_prepaid->{c_id};
|
||||
$feedb->{prepaid_id} = $cttpos->{c_id};
|
||||
$feedb->{prepaid_account} = $ctt_prepaid->{c_id};
|
||||
}
|
||||
}
|
||||
return $feedb;
|
||||
}
|
||||
}#end prepaid_request
|
||||
|
||||
#select rentals for messaging user if bike > 12h ... occupied
|
||||
sub longterm_occupied {
|
||||
|
@ -612,13 +621,10 @@ sub insert_contenttranspos {
|
|||
my $cc_part = { c_id => 0 };
|
||||
$cc_part = $dbt->fetch_record($dbh,$pref_cc) if($R::c_id || $R::json_select);
|
||||
|
||||
my $pref_adr = {
|
||||
table => "contentadr",
|
||||
fetch => "one",
|
||||
c_id => "$ctt->{int10}",
|
||||
my $ctadr = {
|
||||
c_id => $ctt->{int10},
|
||||
txt01 => $ctt->{txt01},
|
||||
};
|
||||
my $ctadr = { c_id => 0 };
|
||||
$ctadr = $dbt->fetch_tablerecord($dbh,$pref_adr) if($ctt->{int10});
|
||||
|
||||
if($cc_part->{c_id}){
|
||||
$cc_part->{int02} = "0" if(!$cc_part->{int02});
|
||||
|
|
|
@ -44,6 +44,52 @@ sub round(){
|
|||
return $rounded;
|
||||
}
|
||||
|
||||
#collect prepaid
|
||||
sub collect_prepaid {
|
||||
my $self = shift;
|
||||
my $dbh = shift;
|
||||
my $ctadr = shift || {};
|
||||
|
||||
my $prepaidhash = {
|
||||
prepaid_total => 0,
|
||||
prepaid_id => 0,
|
||||
};
|
||||
|
||||
if($ctadr->{c_id}){
|
||||
my $posref = {
|
||||
table => "contenttrans",
|
||||
table_pos => "contenttranspos",
|
||||
fetch => "all",
|
||||
keyfield => "c_id",
|
||||
ca_id => "$ctadr->{c_id}",
|
||||
'ct.state' => "is::null",
|
||||
'ct.close_time' => "is::null",
|
||||
};
|
||||
my $cttpos = { c_id => 0 };
|
||||
$cttpos = $dbt->collect_post($dbh,$posref);
|
||||
#TODO negative counting booked operator invoices
|
||||
foreach my $id (sort { $cttpos->{$b}->{c_id} <=> $cttpos->{$a}->{c_id} } keys(%$cttpos)){
|
||||
#print $cttpos->{$id}->{barcode} . ":" . $cttpos->{$id}->{int02},"<br>";
|
||||
|
||||
if($cttpos->{$id}->{barcode} && $cttpos->{$id}->{int02} == 0){
|
||||
$prepaidhash->{prepaid_id} = $cttpos->{$id}->{ct_id} . "-" . $cttpos->{$id}->{c_id};
|
||||
$prepaidhash->{number} = $cttpos->{$id}->{c_id};
|
||||
$prepaidhash->{description} = $cttpos->{$id}->{txt01};
|
||||
}
|
||||
#if($cttpos->{$id}->{barcode} && $cttpos->{$id}->{int02} > 0){
|
||||
# $prepaidhash->{prepay_id_payed} = $cttpos->{$id}->{int02};
|
||||
#}
|
||||
if($cttpos->{$id}->{int02} > 0){
|
||||
$prepaidhash->{prepaid_total} += $cttpos->{$id}->{int02};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$bw->log("Pricing prepaidhash:",$prepaidhash,"");
|
||||
return $prepaidhash;
|
||||
}
|
||||
|
||||
|
||||
#for one freed rental
|
||||
#depends on operator, only 1 rental get freed_time
|
||||
sub count_freedrental {
|
||||
|
|
|
@ -560,11 +560,11 @@ sub save_account(){
|
|||
print FILE "account_check iban:$iban, c_id:$account_check->{c_id} && $account_check->{c_id} != $c_id\n" if($debug);
|
||||
if($account_check->{c_id} && $account_check->{c_id} != $c_id){
|
||||
my $encoded_val = $uri_encode->encode($iban);
|
||||
$ret_conflict = "failure::conflict_txt22=$encoded_val#top";
|
||||
}
|
||||
$ret_conflict = "failure::conflict_txt22\&txt22=$encoded_val#top";
|
||||
}else{
|
||||
|
||||
my $payone_mival = $payone->managemandate_main(\%varenv,$ctadr,"",$owner);
|
||||
if($payone_mival && $payone_mival =~ /\w{2}-\d+/){
|
||||
my $payone_mival = $payone->managemandate_main(\%varenv,$ctadr,"",$owner);
|
||||
if($payone_mival && $payone_mival =~ /\w{2}-\d+/){
|
||||
#define fictiv invoice to get 1 € test
|
||||
my $epoche = time();
|
||||
my $ctt = {
|
||||
|
@ -594,12 +594,13 @@ sub save_account(){
|
|||
}else{
|
||||
$u_rows = $dbt->update_one($dbh,$update_adr,"int12=$vde_on_fail");#Vde
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#prepaid
|
||||
elsif($ctadr->{int03} == 3){
|
||||
$feedb = $pl->prepaid_request($dbh,$ctadr,$owner);
|
||||
$u_rows = $dbt->update_one($dbh,$update_adr,"ct_name='Prepay-$feedb->{prepaid_account}'");#Vde
|
||||
}
|
||||
#prepaid, will be requested in PayoneLink.pm
|
||||
#elsif($ctadr->{int03} == 3){
|
||||
# $feedb = $pl->prepaid_request($dbh,$ctadr,$owner);
|
||||
#}
|
||||
|
||||
if($R::txt04 && $R::confirm_txt04 && $R::txt04 ne $R::confirm_txt04){
|
||||
$ret = "failure::confirm_txt04#top";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue