mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-13 23:26:29 +02:00
content search refactoring and Mahnung
This commit is contained in:
parent
4435999ac2
commit
ad478aa3ee
11 changed files with 308 additions and 114 deletions
|
@ -1192,6 +1192,7 @@ sub booking_update(){
|
|||
c_id => "$record_pos->{c_id}",
|
||||
};
|
||||
$record_pos = $dbt->fetch_tablerecord($dbh,$booking_pos);
|
||||
$bw->log("smartlock lock_state $lock_state | int10 $record_pos->{int10} | int20 $record_pos->{int20}",$booking_values,"");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1261,6 +1262,7 @@ sub booking_update(){
|
|||
#if(state eq available && $record_pos.lock_state eq locked and pos-state 2=requested or 3=occupied
|
||||
}elsif($state_key == 1 && $record_pos->{int20} == 1 && ($record_pos->{int10} == 2 || $record_pos->{int10} == 3)){
|
||||
|
||||
|
||||
#client GPS must have. sigo ist done without client gps
|
||||
if(($gps_data->{gps} && $gps_data->{gps_age_minutes} <= 3) || ($record_pos->{int11} == 3)){
|
||||
#geofencing for Ilockit
|
||||
|
@ -1406,7 +1408,7 @@ sub booking_update(){
|
|||
|
||||
|
||||
#fetch final booking state after request
|
||||
if($record_pos->{c_id} > 0){
|
||||
if($record_pos->{c_id} && $record_pos->{c_id} > 0){
|
||||
my $booking_pos = {
|
||||
table => "contenttranspos",
|
||||
fetch => "one",
|
||||
|
@ -2537,7 +2539,7 @@ sub authout(){
|
|||
my $return = { authcookie => "" };#if fails
|
||||
|
||||
my $cgi_authcookie = $q->param('authcookie') || $coo || "";
|
||||
$bw->log("authout coo:$cgi_authcookie",$q,"");
|
||||
#$bw->log("authout coo:$cgi_authcookie",$q,"");
|
||||
|
||||
if($cgi_authcookie && length($cgi_authcookie) > 20){
|
||||
my $authref = {
|
||||
|
|
|
@ -1219,9 +1219,9 @@ sub insert_nodeoid(){
|
|||
my $node_path = $insert->{node_name};
|
||||
($node_name,$node_path) = split(/\|/,$node_name) if($node_name =~ /\|/);
|
||||
|
||||
my $sth2 = $dbh->prepare("INSERT INTO nodes (main_id,parent_id,lang,node_name,node_path,n_sort,owner,node_public) VALUES('$insert->{main_id}','$insert->{parent_id}','$insert->{lang}','$node_name','$node_path','$insert->{n_sort}','$insert->{owner}','t')");
|
||||
my $sth2 = $dbh->prepare("INSERT INTO nodes (main_id,parent_id,node_name,node_path,n_sort,owner,node_public) VALUES('$insert->{main_id}','$insert->{parent_id}','$node_name','$node_path','$insert->{n_sort}','$insert->{owner}','t')");
|
||||
my $rc = $sth2->execute();
|
||||
$sth2 = $dbh->prepare("INSERT INTO relation (main_id,template_id,content_id,lang,change) VALUES('$insert->{main_id}','$insert->{template_id}','$insert->{content_id}','$insert->{lang}','now()') RETURNING rel_id");
|
||||
$sth2 = $dbh->prepare("INSERT INTO relation (main_id,template_id,content_id,change) VALUES('$insert->{main_id}','$insert->{template_id}','$insert->{content_id}','now()') RETURNING rel_id");
|
||||
$rc = $sth2->execute();
|
||||
|
||||
my $last_id;
|
||||
|
@ -1544,4 +1544,192 @@ sub evaluationsfragen {
|
|||
return $user_miniquery;
|
||||
}
|
||||
|
||||
#search table content.
|
||||
sub search_content(){
|
||||
my $self = shift;
|
||||
my $dbh = shift || $dbh_intern;
|
||||
my $searchref = shift;
|
||||
my $node_meta = shift;
|
||||
my $users_dms = shift;
|
||||
my $main_ids = shift || "";
|
||||
my $tplids = shift || "";
|
||||
my $ct_ids = shift || "";
|
||||
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/,$//;
|
||||
|
||||
my $owner = $users_dms->{u_id};
|
||||
my $sort_updown = $users_dms->{sort_updown};
|
||||
my $scol = $searchref->{scol};
|
||||
my $offset = $searchref->{offset};
|
||||
my $limit = $searchref->{limit};
|
||||
my $export = $searchref->{export};
|
||||
my $opos = $searchref->{opos};
|
||||
|
||||
my $stamp_time = strftime("%d.%m.%Y %H:%M",localtime(time));
|
||||
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 Dumper($searchref) if($debug);
|
||||
print FILE "$table,$node_meta->{node_name},$owner,$main_ids,$tplids,$ct_ids,$v_journal,$ck4ex\n" if($debug);
|
||||
close(FILE) if($debug);
|
||||
|
||||
|
||||
my $table_pos = $searchref->{table_pos} || "";
|
||||
my $txt_where;
|
||||
my $cptxt_where;
|
||||
my $cpgroup_where;
|
||||
|
||||
my $valref = {};
|
||||
my $opref = {};
|
||||
foreach my $key (keys(%$searchref)){
|
||||
if($searchref->{$key} || $searchref->{$key} eq "0"){
|
||||
|
||||
$valref->{$key} = $searchref->{$key};
|
||||
$opref->{$key} = "=";
|
||||
($opref->{$key}, $valref->{$key}) = split(/::/, $searchref->{$key}) if($searchref->{$key} =~ /::/);
|
||||
if($key =~ /table_pos/){
|
||||
$table_pos = $valref->{$key};
|
||||
}
|
||||
if($key =~ /c_id|int\d+|barcode|time|sort|owner/){
|
||||
$searchref->{$key} =~ s/,/./g;
|
||||
if($searchref->{$key} =~ /(\<\=|\>\=|\<|\>|\=)/){
|
||||
$opref->{$key} = $1;
|
||||
}
|
||||
if($searchref->{$key} =~ /([-0-9\.]+)/){
|
||||
$valref->{$key} = $1;
|
||||
}
|
||||
if($searchref->{$key} =~ /null/){
|
||||
$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/){
|
||||
$cptxt_where .= " and cp.$key ilike '$valref->{$key}'";
|
||||
}elsif($key =~ /txt/){
|
||||
$cptxt_where .= " and cp.$key ilike '%$valref->{$key}%'";
|
||||
}elsif($key =~ /barcode|int|owner/ && (looks_like_number($valref->{$key}) || $valref->{$key} eq "null")){
|
||||
$cptxt_where .= " and cp.$key $opref->{$key} $valref->{$key}";
|
||||
}
|
||||
}else{
|
||||
if($key eq "ct_name" && $valref->{$key} =~ /^(\d+)(0\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}'";
|
||||
}elsif($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}";
|
||||
}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}%')";
|
||||
}elsif($key =~ /byte/){
|
||||
$txt_where .= " and ct.$key = '\\x$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/);
|
||||
}
|
||||
elsif($table_pos =~ /contentpos|contentadrpos|users/ && $key eq "template_id_pos" && $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/);
|
||||
}
|
||||
|
||||
}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/);
|
||||
}
|
||||
if($key =~ /start_mtime/ && $valref->{$key} =~ /^\d+$/){
|
||||
$txt_where .= " and ct.int11 = '$valref->{$key}'";#int11 = c_id-abschluss key
|
||||
}elsif($key =~ /start_mtime/ && $valref->{$key} =~ /date.*\d+\.\d+\.\d+/){
|
||||
$txt_where .= " and ct.mtime >= $valref->{$key}";
|
||||
}elsif($key =~ /start_mtime/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
|
||||
$txt_where .= " and ct.mtime >= '$valref->{$key}'";
|
||||
}
|
||||
if($key =~ /end_mtime/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
|
||||
$txt_where .= " and ct.mtime < '$valref->{$key}'";
|
||||
}
|
||||
}
|
||||
if($key =~ /start_pay_time/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
|
||||
$txt_where .= " and ct.pay_time >= '$valref->{$key}'";
|
||||
}
|
||||
if($key =~ /end_pay_time/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
|
||||
$txt_where .= " and ct.pay_time < '$valref->{$key}'";
|
||||
}
|
||||
if($key =~ /start_warn_time/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
|
||||
$txt_where .= " and ct.warn_time >= '$valref->{$key}'";
|
||||
}
|
||||
if($key =~ /end_warn_time/ && $valref->{$key} =~ /\d+\.\d+\.\d+/){
|
||||
$txt_where .= " and ct.warn_time < '$valref->{$key}'";
|
||||
}
|
||||
}
|
||||
}#
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
$txt_where = " and ct.c_id IN ($ck4ex)" if($export =~ /check4export/);
|
||||
my $sth = "";
|
||||
my $updown = "ASC";
|
||||
$updown = "DESC" if($sort_updown eq "down");
|
||||
if($v_journal =~ /_parts/){#collects ct_ids
|
||||
my $cp_scol = "ct_name";
|
||||
$cp_scol = $1 if($scol =~ /(ct_name|barcode|mtime|txt0[1-9]|int0[1-9])/);
|
||||
$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"){
|
||||
if($valref->{template_id_pos} eq 602){#because of user_minianswer have to be anonym
|
||||
$sth = $dbh->prepare("SELECT cp.* FROM contentadrpos cp WHERE 1=1 $cptxt_where ORDER BY cp.$scol $updown LIMIT $limit OFFSET $offset");
|
||||
}else{
|
||||
$sth = $dbh->prepare("SELECT ct.txt01,ct.txt08,cp.c_id,cp.mtime,cp.barcode,cp.int01,cp.txt02 FROM contentadr ct, contentadrpos cp WHERE ct.c_id=cp.ca_id $txt_where $cptxt_where ORDER BY cp.$scol $updown LIMIT $limit OFFSET $offset");
|
||||
}
|
||||
}elsif($table_pos && $table_pos eq "users"){
|
||||
$sth = $dbh->prepare("SELECT cp.* FROM contentadr ct, users cp WHERE ct.c_id=cp.u_id $txt_where $cptxt_where ORDER BY cp.$scol $updown LIMIT $limit OFFSET $offset");
|
||||
|
||||
}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");
|
||||
my $search = $sth->fetchall_hashref("$s_id");
|
||||
|
||||
return $search;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -419,7 +419,7 @@ sub preinit(){
|
|||
$u_rows +=$db->updater("$table","c_id",$c_id,"$_","$valxx");
|
||||
}
|
||||
|
||||
if($_ =~ /mtime/ && $table){
|
||||
if($_ =~ /mtime|warn_time/ && $table){
|
||||
my $timexx = $valxx;
|
||||
$u_rows += $db->update_content4change($table,$c_id,$ct_name,$timexx,$_,$users_dms->{u_id}) if($timexx =~ /\d{1,2}\.\d{1,2}\.\d{2,4}\s\d{1,2}:\d{1,2}/ || $timexx =~ /\d{1,2}\.\d{1,2}\.\d{2,4}$/);
|
||||
}
|
||||
|
|
|
@ -505,6 +505,7 @@ sub operator_accounting2calc {
|
|||
if($key =~ /int/){
|
||||
$oac->{int99} = $ctpos->{int01} if($key eq "int01" && $ctpos->{int01});#invoice capture brutto
|
||||
$oac->{int01} = $ctpos->{int01} / 119 * 100 if($key eq "int01" && $ctpos->{int01});#invoice capture netto
|
||||
$oac->{int01} = sprintf('%.2f', $oac->{int01});
|
||||
|
||||
if($ctpos->{state} =~ /Lastschrift/){
|
||||
$oac->{int93} = $oac->{int01} / 100 * $ctf->{$key} if($key eq "int01");#7,5%
|
||||
|
|
|
@ -442,14 +442,14 @@ td {
|
|||
#int9x are not in db
|
||||
#operator invoice
|
||||
if($ctt->{txt00} eq "Rechnung"){
|
||||
@tpl_order = ("c_id=ID","int01=Netto Erlös","state=Zahlungsart","int93=Entgeld TeilRad GmbH");
|
||||
@tpl_order = ("c_id=ID","int01=Netto Erlös","state=Zahlungsart","int93=Entgelt TeilRad GmbH");
|
||||
}
|
||||
#operator accounting
|
||||
else{
|
||||
if($varenv->{dbname} eq "sharee_sx"){
|
||||
@tpl_order = ("c_id=ID","int01=Netto Erlös","state=Zahlungsart","int94=Disagio","int02=Summe Gutschrift");
|
||||
@tpl_order = ("c_id=ID","int01=Netto Erlös","state=Zahlungsart","int94=Disagio","int02=Gutschrift");
|
||||
}else{
|
||||
@tpl_order = ("c_id=ID","int01=Netto Erlös","state=Zahlungsart","int94=Disagio","int95=Transaktion","int96=Zahlungsmeldung","int97=Kreditkarte Zuordnung","int02=Summe Gutschrift");
|
||||
@tpl_order = ("c_id=ID","int01=Netto Erlös","state=Zahlungsart","int94=Disagio","int95=Transaktion","int96=Zahlungsmeldung","int97=Kreditkarte Zuordnung","int02=Gutschrift");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -548,9 +548,12 @@ td {
|
|||
#Sum Operator invoice
|
||||
if($break_table_wc > 0 && $break_table_wc <= $max_table_wc){
|
||||
|
||||
#print "$ctt->{int01}|$ctt->{int02}|";
|
||||
my $sum_brutto = $ctt->{int01} || 0;
|
||||
$sum_brutto =~ s/,/\./;#hm
|
||||
my $sum_operatorcredit = $ctt->{int02} || 0;
|
||||
my $total_operatorcredit = $sum_operatorcredit - $sum_brutto;
|
||||
$total_operatorcredit =~ s/\./,/;
|
||||
|
||||
if($sum_brutto && $sum_brutto != 0){
|
||||
$sum_umst19 = $sum_brutto / $diff19 * 19;
|
||||
|
@ -611,17 +614,17 @@ td {
|
|||
}
|
||||
|
||||
print $q->Tr("\n");
|
||||
print $q->td({-class=>'tdsum',-colspan=>1},"Entgeld TeilRad GmbH");
|
||||
print $q->td({-class=>'tdsum',-colspan=>1},"Entgelt TeilRad GmbH");
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_brutto €");
|
||||
}
|
||||
#Summe Betreiber Abrechnung (Gutschrift)
|
||||
else{
|
||||
print $q->Tr("\n");
|
||||
print $q->td({-class=>'tdsum',-colspan=>1},"Summe");
|
||||
print $q->td({-class=>'tdsum',-colspan=>1},"Summe Gutschrift");
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"$sum_operatorcredit €");
|
||||
|
||||
print $q->Tr("\n");
|
||||
print $q->td({-class=>'tdsum',-colspan=>1},"Entgeld TeilRad GmbH");
|
||||
print $q->td({-class=>'tdsum',-colspan=>1},"Entgelt TeilRad GmbH");
|
||||
print $q->td({-class=>'tdint',-nowrap=>"1"},"- $sum_brutto €");
|
||||
|
||||
print $q->Tr("\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue