X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fct.pl;h=086565d7d4a20fbc10c1eb88ed2634dcbbf35669;hb=247a26dc4b5b0d73c03fc6f05fb17daace0835d9;hp=2778b4c4a1b2ad05d64fc3a7e5866d74baefbdb9;hpb=5ee512da8640df15463e108f5d427307762e6868;p=kivitendo-erp.git diff --git a/bin/mozilla/ct.pl b/bin/mozilla/ct.pl index 2778b4c4a..086565d7d 100644 --- a/bin/mozilla/ct.pl +++ b/bin/mozilla/ct.pl @@ -36,6 +36,14 @@ # $locale->text('Vendors') # $locale->text('Add Customer') # $locale->text('Add Vendor') +# $locale->text('Edit Customer') +# $locale->text('Edit Vendor') +# $locale->text('Customer saved!') +# $locale->text('Vendor saved!') +# $locale->text('Customer deleted!') +# $locale->text('Cannot delete customer!') +# $locale->text('Vendor deleted!') +# $locale->text('Cannot delete vendor!') use CGI::Ajax; use POSIX qw(strftime); @@ -56,11 +64,8 @@ sub add { $auth->assert('customer_vendor_edit'); - $form->{title} = "Add"; - - $form->{callback} = - "$form->{script}?action=add&db=$form->{db}" - unless $form->{callback}; + $form->{title} = "Add"; + $form->{callback} = "$form->{script}?action=add&db=$form->{db}" unless $form->{callback}; CT->populate_drop_down_boxes(\%myconfig, \%$form); @@ -103,6 +108,8 @@ sub list_names { $form->{IS_CUSTOMER} = $form->{db} eq 'customer'; + report_generator_set_default_sort('name', 1); + CT->search(\%myconfig, \%$form); my $cvar_configs = CVar->get_configs('module' => 'CT'); @@ -154,9 +161,12 @@ sub list_names { my @hidden_variables = (qw(db status obsolete), map { "l_$_" } @columns); my @hidden_nondefault = grep({ $form->{$_} } @hidden_variables); my $callback = build_std_url('action=list_names', grep { $form->{$_} } @hidden_variables); - $form->{callback} = "$callback&sort=" . E($form->{sort}); + $form->{callback} = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir}); - map { $column_defs{$_}->{link} = "${callback}&sort=${_}" } @columns; + foreach (@columns) { + my $sortdir = $form->{sort} eq $_ ? 1 - $form->{sortdir} : $form->{sortdir}; + $column_defs{$_}->{link} = "${callback}&sort=${_}&sortdir=${sortdir}"; + } my ($ordertype, $quotationtype, $attachment_basename); if ($form->{IS_CUSTOMER}) { @@ -187,7 +197,7 @@ sub list_names { $report->set_export_options('list_names', @hidden_variables); - $report->set_sort_indicator($form->{sort}, 1); + $report->set_sort_indicator($form->{sort}, $form->{sortdir}); CVar->add_custom_variables_to_report('module' => 'CT', 'trans_id_field' => 'id', @@ -232,9 +242,6 @@ sub edit { $form->{javascript} = qq||; #/show hhistory button - # $locale->text('Edit Customer') - # $locale->text('Edit Vendor') - CT->get_tuple(\%myconfig, \%$form); CT->populate_drop_down_boxes(\%myconfig, \%$form); @@ -271,21 +278,16 @@ sub form_header { $form->{taxzone_id} = 0 if !$form->{id}; $form->{jsscript} = 1; $form->{fokus} = "ct.greeting"; + $form->{AJAX} = [ new CGI::Ajax( map {; "get_$_" => "$form->{script}?action=get_$_" } qw(shipto contact delivery) ) ]; unshift @{ $form->{SHIPTO} }, +{ shipto_id => '0', shiptoname => '' }, +{ shipto_id => '0', shiptoname => 'Alle' }; unshift @{ $form->{CONTACTS} }, +{ cp_id => '0', cp_name => $locale->text('New contact') }; - push @{ $form->{AJAX} }, map { - new CGI::Ajax( "get_$_" => "$form->{script}?action=get_$_" ) - } qw(shipto contact delivery); - $form->{title} = $form->{title_save} || $locale->text("$form->{title} " . ucfirst $form->{db}) . ($form->{title} eq "Edit" ? " $form->{name}" : ''); -## LINET: Create a drop-down box with all prior titles and greetings. CT->query_titles_and_greetings(\%myconfig, \%$form); map { $form->{"MB_$_"} = [ map +{ id => $_, description => $_ }, @{ $form->{$_} } ] } qw(TITLES GREETINGS COMPANY_GREETINGS DEPARTMENT); -## /LINET $form->{NOTES} ||= [ ]; @@ -454,9 +456,6 @@ sub save_and_close { $auth->assert('customer_vendor_edit'); - # $locale->text('Customer saved!') - # $locale->text('Vendor saved!') - $msg = ucfirst $form->{db}; $imsg .= " saved!"; @@ -486,9 +485,6 @@ sub save { $auth->assert('customer_vendor_edit'); - # $locale->text('Customer saved!') - # $locale->text('Vendor saved!') - $msg = ucfirst $form->{db}; $imsg .= " saved!"; @@ -525,11 +521,6 @@ sub delete { $auth->assert('customer_vendor_edit'); - # $locale->text('Customer deleted!') - # $locale->text('Cannot delete customer!') - # $locale->text('Vendor deleted!') - # $locale->text('Cannot delete vendor!') - CT->delete(\%myconfig, \%$form); $msg = ucfirst $form->{db}; @@ -575,9 +566,8 @@ sub get_contact { $auth->assert('customer_vendor_edit'); CT->get_contact(\%myconfig, \%$form); - print $cgi->header(), join '__pjx__', map $form->{"cp_$_"}, - qw(name greeting title givenname phone1 phone2 email abteilung fax mobile1 mobile2 satphone satfax project privatphone privatemail birthday); + qw(name greeting title givenname phone1 phone2 email abteilung fax mobile1 mobile2 satphone satfax project privatphone privatemail birthday used); $lxdebug->leave_sub(); } @@ -588,9 +578,8 @@ sub get_shipto { $auth->assert('customer_vendor_edit'); CT->get_shipto(\%myconfig, \%$form); - print $cgi->header(), join '__pjx__', map $form->{"shipto$_"}, - qw(name department_1 department_2 street zipcode city country contact phone fax email); + qw(name department_1 department_2 street zipcode city country contact phone fax email used); $lxdebug->leave_sub(); } @@ -607,4 +596,38 @@ sub get_delivery { $lxdebug->leave_sub(); } +sub delete_shipto { + $main::lxdebug->enter_sub(); + + $auth->assert('customer_vendor_edit'); + + CT->get_shipto(\%myconfig, \%$form); + + unless ($form->{shiptoused}) { + CT->delete_shipto($form->{shipto_id}); + @$form{ grep /^shipto/, keys %$form } = undef; + } + + edit(); + + $main::lxdebug->leave_sub(); +} + +sub delete_contact { + $main::lxdebug->enter_sub(); + + $auth->assert('customer_vendor_edit'); + + CT->get_contact(\%myconfig, \%$form); + + unless ($form->{cp_used}) { + CT->delete_shipto($form->{cp_id}); + @$form{ grep /^cp_/, keys %$form } = undef; + } + + edit(); + + $main::lxdebug->leave_sub(); +} + sub continue { call_sub($form->{nextsub}); }