Revision 79b75e07
Von Jan Büren vor mehr als 3 Jahren hinzugefügt
bin/mozilla/wh.pl | ||
---|---|---|
41 | 41 |
use SL::AM; |
42 | 42 |
use SL::CVar; |
43 | 43 |
use SL::CT; |
44 |
use SL::Helper::Flash qw(flash_later); |
|
44 | 45 |
use SL::IC; |
45 | 46 |
use SL::WH; |
46 | 47 |
use SL::OE; |
48 |
# use SL::Helper::Inventory qw(produce_assembly); |
|
47 | 49 |
use SL::Locale::String qw(t8); |
48 | 50 |
use SL::ReportGenerator; |
51 |
use SL::Presenter::Tag qw(checkbox_tag); |
|
49 | 52 |
use SL::Presenter::Part; |
50 | 53 |
|
54 |
use SL::DB::AssemblyInventoryPart; |
|
51 | 55 |
use SL::DB::Part; |
52 | 56 |
|
53 | 57 |
use Data::Dumper; |
... | ... | |
547 | 551 |
$main::lxdebug->leave_sub(); |
548 | 552 |
} |
549 | 553 |
|
554 |
sub disassemble_assembly { |
|
555 |
$main::lxdebug->enter_sub(); |
|
556 |
|
|
557 |
$main::auth->assert('warehouse_management'); |
|
558 |
|
|
559 |
my $form = $main::form; |
|
560 |
|
|
561 |
croak("No assembly ids") unless scalar @{ $form->{ids}} > 0; |
|
562 |
|
|
563 |
# fail safe, only allow disassemble in certain intervals |
|
564 |
my $undo_date = DateTime->today->subtract(days => $::instance_conf->get_undo_transfer_interval); |
|
565 |
|
|
566 |
foreach my $assembly_id (@{ $::form->{ids}} ) { |
|
567 |
my $assembly_parts; |
|
568 |
$assembly_parts = SL::DB::Manager::AssemblyInventoryPart->get_all(where => [ inventory_assembly_id => $assembly_id ]); |
|
569 |
$form->show_generic_error(t8('No relations found for #1', $assembly_id)) unless $assembly_parts; |
|
570 |
# check first entry for insertdate |
|
571 |
# everything in one transaction |
|
572 |
my $db = SL::DB::Inventory->new->db; |
|
573 |
$db->with_transaction(sub { |
|
574 |
my ($assembly_entry, $part_entry); |
|
575 |
foreach my $assembly_part (@{ $assembly_parts }) { |
|
576 |
die("No valid entry found") unless (ref($assembly_part) eq 'SL::DB::AssemblyInventoryPart'); |
|
577 |
# fail safe undo date |
|
578 |
die("Invalid time interval") unless DateTime->compare($assembly_part->itime, $undo_date); |
|
579 |
|
|
580 |
$assembly_entry //= $assembly_part->assembly; |
|
581 |
$part_entry = $assembly_part->part; |
|
582 |
$assembly_part->delete; |
|
583 |
$part_entry->delete; |
|
584 |
} |
|
585 |
flash_later('info', t8("Disassembly successful for #1", $assembly_entry->part->partnumber)); |
|
586 |
|
|
587 |
$assembly_entry->delete; |
|
588 |
|
|
589 |
1; |
|
590 |
|
|
591 |
}) || die t8('error while disassembling assembly #1 : #2', $assembly_id) . $db->error . "\n"; |
|
592 |
|
|
593 |
} |
|
594 |
$main::lxdebug->leave_sub(); |
|
595 |
$form->redirect; |
|
596 |
} |
|
597 |
|
|
550 | 598 |
# -------------------------------------------------------------------- |
551 | 599 |
# Journal |
552 | 600 |
# -------------------------------------------------------------------- |
... | ... | |
583 | 631 |
my %myconfig = %main::myconfig; |
584 | 632 |
my $locale = $main::locale; |
585 | 633 |
|
634 |
setup_wh_journal_list_all_action_bar(); |
|
586 | 635 |
$form->{title} = $locale->text("WHJournal"); |
587 | 636 |
$form->{sort} ||= 'date'; |
588 | 637 |
|
589 | 638 |
$form->{report_generator_output_format} = 'HTML' if !$form->{report_generator_output_format}; |
590 | 639 |
|
591 | 640 |
my %filter; |
592 |
my @columns = qw(trans_id date warehouse_from bin_from warehouse_to bin_to partnumber type_and_classific partdescription chargenumber bestbefore trans_type comment qty unit partunit employee oe_id projectnumber); |
|
641 |
my @columns = qw(ids trans_id date warehouse_from bin_from warehouse_to bin_to partnumber type_and_classific partdescription chargenumber bestbefore trans_type comment qty unit partunit employee oe_id projectnumber);
|
|
593 | 642 |
|
594 | 643 |
# filter stuff |
595 | 644 |
map { $filter{$_} = $form->{$_} if ($form->{$_}) } qw(warehouse_id bin_id classification_id partnumber description chargenumber bestbefore transtype_id transtype_ids comment projectnumber); |
... | ... | |
634 | 683 |
push @hidden_variables, qw(classification_id); |
635 | 684 |
|
636 | 685 |
my %column_defs = ( |
686 |
'ids' => { raw_header_data => checkbox_tag("", id => "check_all", checkall => "[data-checkall=1]") }, |
|
637 | 687 |
'date' => { 'text' => $locale->text('Date'), }, |
638 | 688 |
'trans_id' => { 'text' => $locale->text('Trans Id'), }, |
639 | 689 |
'trans_type' => { 'text' => $locale->text('Trans Type'), }, |
... | ... | |
674 | 724 |
$column_defs{partunit}->{visible} = 1; |
675 | 725 |
$column_defs{type_and_classific}->{visible} = 1; |
676 | 726 |
$column_defs{type_and_classific}->{link} =''; |
727 |
$column_defs{ids}->{visible} = 1; |
|
677 | 728 |
|
678 | 729 |
$report->set_columns(%column_defs); |
679 | 730 |
$report->set_column_order(@columns); |
... | ... | |
706 | 757 |
$entry->{type_and_classific} = SL::Presenter::Part::type_abbreviation($entry->{part_type}) . |
707 | 758 |
SL::Presenter::Part::classification_abbreviation($entry->{classification_id}); |
708 | 759 |
$entry->{qty} = $form->format_amount(\%myconfig, $entry->{qty}); |
760 |
$entry->{assembled} = $entry->{trans_type} eq 'assembled' ? 1 : ''; |
|
709 | 761 |
$entry->{trans_type} = $locale->text($entry->{trans_type}); |
710 |
|
|
711 | 762 |
my $row = { }; |
712 | 763 |
|
713 | 764 |
foreach my $column (@columns) { |
... | ... | |
717 | 768 |
}; |
718 | 769 |
} |
719 | 770 |
|
720 |
$row->{trans_type}->{raw_data} = $entry->{trans_type};
|
|
771 |
$row->{ids}->{raw_data} = checkbox_tag("ids[]", value => $entry->{id}, "data-checkall" => 1) if $entry->{assembled};
|
|
721 | 772 |
|
773 |
$row->{trans_type}->{raw_data} = $entry->{trans_type}; |
|
722 | 774 |
if ($form->{l_oe_id}) { |
723 | 775 |
$row->{oe_id}->{data} = ''; |
724 | 776 |
my $info = $entry->{oe_id_info}; |
... | ... | |
735 | 787 |
$idx++; |
736 | 788 |
} |
737 | 789 |
|
790 |
|
|
791 |
$report->set_options( |
|
792 |
raw_top_info_text => $form->parse_html_template('wh/report_top'), |
|
793 |
raw_bottom_info_text => $form->parse_html_template('wh/report_bottom', { callback => $href }), |
|
794 |
); |
|
738 | 795 |
if ( ! $allrows ) { |
739 | 796 |
$pages->{max} = SL::DB::Helper::Paginated::ceil($form->{maxrows}, $pages->{per_page}) || 1; |
740 | 797 |
$pages->{page} = $page < 1 ? 1: $page > $pages->{max} ? $pages->{max}: $page; |
741 | 798 |
$pages->{common} = [ grep { $_->{visible} } @{ SL::DB::Helper::Paginated::make_common_pages($pages->{page}, $pages->{max}) } ]; |
742 | 799 |
|
743 |
$report->set_options('raw_bottom_info_text' => $form->parse_html_template('common/paginate', |
|
800 |
$report->set_options('raw_bottom_info_text' => $form->parse_html_template('wh/report_bottom', { callback => $href }) . $form->parse_html_template('common/paginate',
|
|
744 | 801 |
{ 'pages' => $pages , 'base_url' => $href.'&sort='.$form->{sort}.'&order='.$form->{order}}) ); |
745 | 802 |
} |
746 | 803 |
$report->generate_with_headers(); |
... | ... | |
1190 | 1247 |
); |
1191 | 1248 |
} |
1192 | 1249 |
} |
1250 |
sub setup_wh_journal_list_all_action_bar { |
|
1251 |
my ($action) = @_; |
|
1252 |
for my $bar ($::request->layout->get('actionbar')) { |
|
1253 |
$bar->add( |
|
1254 |
combobox => [ |
|
1255 |
action => [ t8('Actions') ], |
|
1256 |
action => [ |
|
1257 |
t8('Disassemble Assembly'), |
|
1258 |
submit => [ '#form', { action => 'disassemble_assembly' } ], |
|
1259 |
checks => [ [ 'kivi.check_if_entries_selected', '[name="ids[]"]' ] ], |
|
1260 |
], |
|
1261 |
], |
|
1262 |
); |
|
1263 |
} |
|
1264 |
} |
|
1265 |
|
|
1193 | 1266 |
|
1194 | 1267 |
1; |
1195 | 1268 |
|
Auch abrufbar als: Unified diff
Gefertigte Erzeugnisse wieder zerlegen
1 Ebene und Prüfung auf transfer_undo Intervall