mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-23 04:06:27 +01:00
rental editor fix and firmware
This commit is contained in:
parent
80f7e5efe2
commit
72dcd2ec13
7 changed files with 55 additions and 36 deletions
|
@ -565,7 +565,7 @@ sub collect_post(){
|
||||||
my $ct_where = "1=1";
|
my $ct_where = "1=1";
|
||||||
my $cp_where = "1=1";
|
my $cp_where = "1=1";
|
||||||
my $ctcp_where = "1=1";
|
my $ctcp_where = "1=1";
|
||||||
my $poscid;
|
my $poscid = "";
|
||||||
|
|
||||||
if($fetch->{table} eq "content" && $fetch->{table_pos} eq "contentpos"){
|
if($fetch->{table} eq "content" && $fetch->{table_pos} eq "contentpos"){
|
||||||
#*2
|
#*2
|
||||||
|
|
|
@ -391,7 +391,7 @@ sub handler {
|
||||||
|
|
||||||
#DMS insert part or fee
|
#DMS insert part or fee
|
||||||
if($node_meta->{ct_table} eq "contenttranspos" && $R::insert_contenttranspos){
|
if($node_meta->{ct_table} eq "contenttranspos" && $R::insert_contenttranspos){
|
||||||
$return = $pl->insert_contenttranspos($R::c_id,$R::ca_id,$R::ct_id,$users_dms->{u_id});
|
$return = $pl->insert_contenttranspos($R::cc_id,$R::ca_id,$R::ct_id,$users_dms->{u_id});
|
||||||
}
|
}
|
||||||
|
|
||||||
$users_dms = $dbt->select_users($dbh,$users_dms->{u_id},"");#just to get update after save
|
$users_dms = $dbt->select_users($dbh,$users_dms->{u_id},"");#just to get update after save
|
||||||
|
|
|
@ -55,7 +55,7 @@ my $debug=1;
|
||||||
#part or fee to invoice
|
#part or fee to invoice
|
||||||
sub insert_contenttranspos {
|
sub insert_contenttranspos {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $c_id = shift || "";#part
|
my $cc_id = shift || "";#part
|
||||||
my $ca_id = shift || "";#adr
|
my $ca_id = shift || "";#adr
|
||||||
my $ct_id = shift || "";#invoice
|
my $ct_id = shift || "";#invoice
|
||||||
my $owner = shift || "";
|
my $owner = shift || "";
|
||||||
|
@ -63,39 +63,56 @@ sub insert_contenttranspos {
|
||||||
my $dbh = "";
|
my $dbh = "";
|
||||||
my $feedb = { message => "" };
|
my $feedb = { message => "" };
|
||||||
|
|
||||||
if(looks_like_number($c_id) && looks_like_number($ca_id) && looks_like_number($ct_id)){
|
if(looks_like_number($cc_id) && looks_like_number($ca_id) && looks_like_number($ct_id)){
|
||||||
my $pref_cc = {
|
my $pref = {
|
||||||
|
table => "contenttrans",
|
||||||
|
table_pos => "contenttranspos",
|
||||||
|
fetch => "one",
|
||||||
|
template_id => "218",#Mietjournal tpl_id
|
||||||
|
ct_id => $ct_id,
|
||||||
|
"ct.state" => "is::null",
|
||||||
|
};
|
||||||
|
|
||||||
|
my $ctpos = { c_id => 0 };
|
||||||
|
$ctpos = $dbt->collect_post($dbh,$pref);
|
||||||
|
|
||||||
|
if($ctpos->{c_id}){
|
||||||
|
|
||||||
|
my $pref_cc = {
|
||||||
table => "content",
|
table => "content",
|
||||||
fetch => "one",
|
fetch => "one",
|
||||||
template_id => "IN::(229)",
|
template_id => "IN::(229)",
|
||||||
c_id => $c_id,
|
c_id => $cc_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
my $cc_part = { c_id => 0 };
|
my $cc_part = { c_id => 0 };
|
||||||
$cc_part = $dbt->fetch_record($dbh,$pref_cc);
|
$cc_part = $dbt->fetch_record($dbh,$pref_cc);
|
||||||
|
|
||||||
my $pref_ca = {
|
my $pref_ca = {
|
||||||
table => "contentadr",
|
table => "contentadr",
|
||||||
fetch => "one",
|
fetch => "one",
|
||||||
template_id => "202",
|
template_id => "202",
|
||||||
c_id => "$ca_id",
|
c_id => "$ca_id",
|
||||||
};
|
};
|
||||||
my $ctadr = { c_id => 0 };
|
my $ctadr = { c_id => 0 };
|
||||||
$ctadr = $dbt->fetch_record($dbh,$pref_ca);
|
$ctadr = $dbt->fetch_record($dbh,$pref_ca);
|
||||||
|
|
||||||
my $pos_id = 0;
|
my $pos_id = 0;
|
||||||
if($cc_part->{int02}){
|
if($cc_part->{int02}){
|
||||||
$pos_id = $dbt->insert_pos($dbh,$ct_id,$cc_part,"",$ctadr,"","",$cc_part->{barcode},"0",$owner,"");
|
$pos_id = $dbt->insert_pos($dbh,$ct_id,$cc_part,"",$ctadr,"","",$cc_part->{barcode},"0",$owner,"");
|
||||||
}else{
|
}else{
|
||||||
$feedb->{message} = "failure::Fehler, VK Preis von Artikel Nr. $cc_part->{barcode} nicht definiert.";
|
$feedb->{message} = "failure::Fehler, VK Preis von Artikel Nr. $cc_part->{barcode} nicht definiert.";
|
||||||
}
|
}
|
||||||
if($pos_id > 0){
|
if($pos_id > 0){
|
||||||
$i_rows += 1;
|
$i_rows += 1;
|
||||||
$dbt->update_content4comp($dbh,$cc_part->{c_id},"-","1");
|
$dbt->update_content4comp($dbh,$cc_part->{c_id},"-","1");
|
||||||
$feedb->{message} = "Artikel Nr. $cc_part->{barcode} erfolgreich hinzugefügt.";
|
$feedb->{message} = "Artikel Nr. $cc_part->{barcode} erfolgreich hinzugefügt.";
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
$feedb->{message} = "failure::Fehler, die Rechnung ist bereits gebucht. Das hinzufügen einer weiteren Rechnungsposition wird somit abgelehnt.";
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
$feedb->{message} = "failure::Fehler, es fehlt mindestens ein Key! ($c_id && $ca_id && $ct_id)";
|
$feedb->{message} = "failure::Fehler, es fehlt mindestens ein Key! ($cc_id && $ca_id && $ct_id)";
|
||||||
}
|
}
|
||||||
$feedb->{u_rows} = $u_rows;
|
$feedb->{u_rows} = $u_rows;
|
||||||
return $feedb;
|
return $feedb;
|
||||||
|
@ -162,10 +179,10 @@ sub save_contenttranspos {
|
||||||
fetch => "one",
|
fetch => "one",
|
||||||
template_id => "218",#Mietjournal tpl_id
|
template_id => "218",#Mietjournal tpl_id
|
||||||
c_id => $c_id,
|
c_id => $c_id,
|
||||||
"ct.close_time" => "is::null",
|
"ct.state" => "is::null",
|
||||||
};
|
};
|
||||||
|
|
||||||
my $ctpos = {};
|
my $ctpos = { c_id => 0 };
|
||||||
$ctpos = $dbt->collect_post($dbh,$pref);
|
$ctpos = $dbt->collect_post($dbh,$pref);
|
||||||
|
|
||||||
my $pricing = {};
|
my $pricing = {};
|
||||||
|
@ -200,12 +217,13 @@ sub save_contenttranspos {
|
||||||
if($ctpos->{c_id}){
|
if($ctpos->{c_id}){
|
||||||
$u_rows += $dbt->update_record($dbh,$update_pos,$ctpos);
|
$u_rows += $dbt->update_record($dbh,$update_pos,$ctpos);
|
||||||
}else{
|
}else{
|
||||||
$feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits abgeschlossen";
|
$feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits gebucht";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#again to get setted date-times
|
#again to get setted date-times
|
||||||
$ctpos = $dbt->collect_post($dbh,$pref);
|
$ctpos = $dbt->collect_post($dbh,$pref);
|
||||||
|
|
||||||
|
#print "$R::start_date $s_hh:$s_mi | $R::start_date $e_hh:$e_mi xxxxxxxxx<br>";exit;
|
||||||
($pricing,$counting) = $pri->counting_rental(\%varenv,$ctpos,"calc_price");
|
($pricing,$counting) = $pri->counting_rental(\%varenv,$ctpos,"calc_price");
|
||||||
$update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38}));
|
$update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38}));
|
||||||
$update_pos->{int39} = "$counting->{int39}" if(looks_like_number($counting->{int39}));
|
$update_pos->{int39} = "$counting->{int39}" if(looks_like_number($counting->{int39}));
|
||||||
|
@ -229,7 +247,7 @@ sub save_contenttranspos {
|
||||||
template_id => "218",#Mietjournal tpl_id
|
template_id => "218",#Mietjournal tpl_id
|
||||||
start_time => ">::$end_time",
|
start_time => ">::$end_time",
|
||||||
barcode => $ctpos->{barcode},
|
barcode => $ctpos->{barcode},
|
||||||
"ct.close_time" => "is::null",
|
"ct.state" => "is::null",
|
||||||
};
|
};
|
||||||
|
|
||||||
my $ctpos2ck = { c_id => 0 };
|
my $ctpos2ck = { c_id => 0 };
|
||||||
|
@ -273,7 +291,7 @@ sub save_contenttranspos {
|
||||||
$u_rows += $dbt->update_record($dbh,$ctpref,$ctpref);
|
$u_rows += $dbt->update_record($dbh,$ctpref,$ctpref);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits abgeschlossen";
|
$feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits gebucht";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -289,10 +307,10 @@ sub save_contenttranspos {
|
||||||
fetch => "one",
|
fetch => "one",
|
||||||
template_id => "218",#Mietjournal tpl_id
|
template_id => "218",#Mietjournal tpl_id
|
||||||
c_id => $c_id,
|
c_id => $c_id,
|
||||||
"ct.close_time" => "is::null",
|
"ct.state" => "is::null",
|
||||||
};
|
};
|
||||||
|
|
||||||
my $ctpos = {};
|
my $ctpos = { c_id => 0 };
|
||||||
$ctpos = $dbt->collect_post($dbh,$pref);
|
$ctpos = $dbt->collect_post($dbh,$pref);
|
||||||
|
|
||||||
my $update_pos = {
|
my $update_pos = {
|
||||||
|
@ -307,7 +325,7 @@ sub save_contenttranspos {
|
||||||
if($ctpos->{c_id}){
|
if($ctpos->{c_id}){
|
||||||
$u_rows += $dbt->update_record($dbh,$update_pos,$ctpos);
|
$u_rows += $dbt->update_record($dbh,$update_pos,$ctpos);
|
||||||
}else{
|
}else{
|
||||||
$feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits abgeschlossen";
|
$feedb->{message} = "failure::Fehler, Änderung abgelehnt da Rechnung bereits gebucht";
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$feedb->{message} = "failure::Fehler, es sind nur numerische Werte erlaubt.";
|
$feedb->{message} = "failure::Fehler, es sind nur numerische Werte erlaubt.";
|
||||||
|
|
|
@ -98,9 +98,10 @@ sub counting_rental {
|
||||||
|
|
||||||
my $computed_end_time = $ctpos->{end_time} || $today4db;
|
my $computed_end_time = $ctpos->{end_time} || $today4db;
|
||||||
$computed_end_time = $today4db if($ctpos->{int10} && $ctpos->{int10} == 3);
|
$computed_end_time = $today4db if($ctpos->{int10} && $ctpos->{int10} == 3);
|
||||||
|
my $computed_start_time = $ctpos->{start_time} || $today4db;#should be only used on parts
|
||||||
|
|
||||||
#main counting rental time and convert it to minute
|
#main counting rental time and convert it to minute
|
||||||
my $dt0 = DateTime::Format::Pg->parse_datetime($ctpos->{start_time});
|
my $dt0 = DateTime::Format::Pg->parse_datetime($computed_start_time);
|
||||||
my $dt1 = DateTime::Format::Pg->parse_datetime($computed_end_time);
|
my $dt1 = DateTime::Format::Pg->parse_datetime($computed_end_time);
|
||||||
my $dur10 = $dt1->subtract_datetime($dt0);
|
my $dur10 = $dt1->subtract_datetime($dt0);
|
||||||
my ($durdd,$durhh,$durmm) = $dur10->in_units( 'days', 'hours','minutes' );
|
my ($durdd,$durhh,$durmm) = $dur10->in_units( 'days', 'hours','minutes' );
|
||||||
|
@ -247,7 +248,7 @@ sub counting_rental {
|
||||||
$total_price = sprintf('%.2f', $total_price);
|
$total_price = sprintf('%.2f', $total_price);
|
||||||
$total_price = $total_price * $ctpos->{int01} if($ctpos->{int01});
|
$total_price = $total_price * $ctpos->{int01} if($ctpos->{int01});
|
||||||
|
|
||||||
$return->{start_time} = "$ctpos->{start_time}";
|
$return->{start_time} = "$computed_start_time";
|
||||||
$return->{end_time} = "$computed_end_time";
|
$return->{end_time} = "$computed_end_time";
|
||||||
$return->{freed_time} = "$freed_time";
|
$return->{freed_time} = "$freed_time";
|
||||||
$return->{computed_hours} = "$computed_hours";
|
$return->{computed_hours} = "$computed_hours";
|
||||||
|
|
|
@ -246,8 +246,8 @@ td {
|
||||||
$position = "position:absolute; top: $h_toppx;" if($h_top);
|
$position = "position:absolute; top: $h_toppx;" if($h_top);
|
||||||
|
|
||||||
my $height = "120px;";
|
my $height = "120px;";
|
||||||
my $margin = "0 0 200px 0;";
|
my $margin = "0 0 100px 0;";
|
||||||
if($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern"){
|
if($dbt->{operator}->{$varenv{dbname}}->{project} =~ /Bayern|Freiburg/){
|
||||||
$height = "200px;";
|
$height = "200px;";
|
||||||
$margin = "0;";
|
$margin = "0;";
|
||||||
}
|
}
|
||||||
|
@ -262,8 +262,8 @@ td {
|
||||||
$ctt->{txt01} = $lb->newline($ctt->{txt01},"","0");
|
$ctt->{txt01} = $lb->newline($ctt->{txt01},"","0");
|
||||||
|
|
||||||
my $height = "120px;";
|
my $height = "120px;";
|
||||||
my $margin = "0 0 200px 0;";
|
my $margin = "0 0 100px 0;";
|
||||||
if($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern"){
|
if($dbt->{operator}->{$varenv{dbname}}->{project} =~ /Bayern|Freiburg/){
|
||||||
$height = "200px;";
|
$height = "200px;";
|
||||||
$margin = "0;";
|
$margin = "0;";
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ sub tpl(){
|
||||||
$search = { %$search,
|
$search = { %$search,
|
||||||
start_date_time => "$start_date_time",
|
start_date_time => "$start_date_time",
|
||||||
end_date_time => "$end_date_time",
|
end_date_time => "$end_date_time",
|
||||||
} if(!$R::cttpos_id);
|
} if(!$R::cttpos_id && !$R::ct_id);
|
||||||
|
|
||||||
#$search->{barcode} = $q->escapeHTML("$R::barcode") if($R::base_edit eq "save_pos" && $R::barcode);
|
#$search->{barcode} = $q->escapeHTML("$R::barcode") if($R::base_edit eq "save_pos" && $R::barcode);
|
||||||
$search->{ct_id} = $q->escapeHTML("$R::ct_id") if($R::ct_id);#done on save_pos and insert fee
|
$search->{ct_id} = $q->escapeHTML("$R::ct_id") if($R::ct_id);#done on save_pos and insert fee
|
||||||
|
|
|
@ -417,8 +417,8 @@ sub tpl(){
|
||||||
#$ctrel = $db->get_ctrel("contenttrans","",$lang,"",$users_dms->{c_id4trans},$users_dms->{tpl_id4trans});
|
#$ctrel = $db->get_ctrel("contenttrans","",$lang,"",$users_dms->{c_id4trans},$users_dms->{tpl_id4trans});
|
||||||
|
|
||||||
#without limit it will takes only one dataset
|
#without limit it will takes only one dataset
|
||||||
#if(($R::rel_id && $R::rel_id =~ /^\d+$/) || ($c_id4trans && $c_id4trans =~ /^\d+$/))
|
if(($R::rel_id && $R::rel_id =~ /^\d+$/) || ($c_id4trans && $c_id4trans =~ /^\d+$/)){
|
||||||
if((($R::rel_id && $R::rel_id =~ /^\d+$/) || ($c_id4trans && $c_id4trans =~ /^\d+$/)) && ($limit > $varenv{limit})){
|
#if((($R::rel_id && $R::rel_id =~ /^\d+$/) || ($c_id4trans && $c_id4trans =~ /^\d+$/)) && ($limit > $varenv{limit})){
|
||||||
$ct4rel = $db->collect_cid($table,$lang,$tpl_id,$R::rel_id,$R::barcode,"c_id",$c_id4trans);
|
$ct4rel = $db->collect_cid($table,$lang,$tpl_id,$R::rel_id,$R::barcode,"c_id",$c_id4trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -827,7 +827,7 @@ sub tpl(){
|
||||||
|
|
||||||
#fee2pos
|
#fee2pos
|
||||||
if($table eq "content" && ($ct4rel->{$id}->{template_id} =~ /229/) && $R::ca_id && $R::ct_id){
|
if($table eq "content" && ($ct4rel->{$id}->{template_id} =~ /229/) && $R::ca_id && $R::ct_id){
|
||||||
print $q->a({-class=>"editnav",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Mietjournal?insert_contenttranspos=1\&c_id=$ct4rel->{$id}->{c_id}\&ca_id=$R::ca_id\&ct_id=$R::ct_id\&owner=$users_dms->{u_id}",-title=>"Gebühr hinzufügen"}, $q->img({-src=>"$varenv{metahost}/glyphicons/glyphicons-512-copy.png", -style=>'height:1.3em;'}));
|
print $q->a({-class=>"editnav",-href=>"/$dbt->{shareedms_conf}->{parent_node}/Mietjournal?insert_contenttranspos=1\&cc_id=$ct4rel->{$id}->{c_id}\&ca_id=$R::ca_id\&ct_id=$R::ct_id\&owner=$users_dms->{u_id}",-title=>"Gebühr hinzufügen"}, $q->img({-src=>"$varenv{metahost}/glyphicons/glyphicons-512-copy.png", -style=>'height:1.3em;'}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($table eq "content" && ($ct4rel->{$id}->{template_id} =~ /205|225/)){
|
if($table eq "content" && ($ct4rel->{$id}->{template_id} =~ /205|225/)){
|
||||||
|
|
Loading…
Add table
Reference in a new issue