Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 92331b8e

Von Moritz Bunkus vor etwa 14 Jahren hinzugefügt

  • ID 92331b8e3417f4a28db17f7af1b8154e985c4da1
  • Vorgänger 250fa402
  • Nachfolger b7b8a0ff

Bearbeiten der Konfiguration für wiederkehrende Rechnungen implementiert

Zzgl. der Suchfunktionserweiterung bei Aufträgen

Unterschiede anzeigen:

SL/Form.pm
use SL::Auth::DB;
use SL::Auth::LDAP;
use SL::AM;
use SL::DB;
use SL::Common;
use SL::DBUtils;
use SL::Mailer;
......
undef $standard_dbh;
}
$standard_dbh ||= $self->dbconnect_noauto($myconfig);
$standard_dbh ||= SL::DB::create->dbh;
$main::lxdebug->leave_sub(2);
SL/OE.pm
package OE;
use List::Util qw(max first);
use YAML;
use SL::AM;
use SL::Common;
use SL::CVar;
use SL::DB::PeriodicInvoicesConfig;
use SL::DBUtils;
use SL::IC;
......
my @values;
my $where;
my ($periodic_invoices_columns, $periodic_invoices_joins);
my $rate = ($form->{vc} eq 'customer') ? 'buy' : 'sell';
if ($form->{type} =~ /_quotation$/) {
$quotation = '1';
$ordnumber = 'quonumber';
} elsif ($form->{type} eq 'sales_order') {
$periodic_invoices_columns = qq| , COALESCE(pcfg.active, 'f') AS periodic_invoices |;
$periodic_invoices_joins = qq| LEFT JOIN periodic_invoices_configs pcfg ON (o.id = pcfg.oe_id) |;
}
my $vc = $form->{vc} eq "customer" ? "customer" : "vendor";
......
qq| pr.projectnumber AS globalprojectnumber, | .
qq| e.name AS employee, s.name AS salesman, | .
qq| ct.${vc}number AS vcnumber, ct.country, ct.ustid | .
$periodic_invoices_columns .
qq|FROM oe o | .
qq|JOIN $vc ct ON (o.${vc}_id = ct.id) | .
qq|LEFT JOIN employee e ON (o.employee_id = e.id) | .
......
qq|LEFT JOIN exchangerate ex ON (ex.curr = o.curr | .
qq| AND ex.transdate = o.transdate) | .
qq|LEFT JOIN project pr ON (o.globalproject_id = pr.id) | .
qq|$periodic_invoices_joins | .
qq|WHERE (o.quotation = ?) |;
push(@values, $quotation);
......
push(@values, '%' . $form->{transaction_description} . '%');
}
if ($form->{periodic_invoices_active} ne $form->{periodic_invoices_inactive}) {
my $not = 'NOT' if ($form->{periodic_invoices_inactive});
$query .= qq| AND ${not} COALESCE(pcfg.active, 'f')|;
}
my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC';
my $sortorder = join(', ', map { "${_} ${sortdir} " } ("o.id", $form->sort_columns("transdate", $ordnumber, "name")));
my %allowed_sort_columns = (
......
my ($self, $myconfig, $form) = @_;
# connect to database, turn off autocommit
my $dbh = $form->dbconnect_noauto($myconfig);
my $dbh = $form->get_standard_dbh;
my ($query, @values, $sth, $null);
my $exchangerate = 0;
......
}
}
$self->save_periodic_invoices_config(dbh => $dbh,
oe_id => $form->{id},
config_yaml => $form->{periodic_invoices_config})
if ($form->{type} eq 'sales_order');
$form->{saved_xyznumber} = $form->{$form->{type} =~ /_quotation$/ ?
"quonumber" : "ordnumber"};
Common::webdav_folder($form) if ($main::webdav);
my $rc = $dbh->commit;
$dbh->disconnect;
$main::lxdebug->leave_sub();
return $rc;
}
sub save_periodic_invoices_config {
my ($self, %params) = @_;
return if !$params{oe_id};
my $config = $params{config_yaml} ? YAML::Load($params{config_yaml}) : undef;
return if 'HASH' ne ref $config;
my $obj = SL::DB::Manager::PeriodicInvoicesConfig->find_by(oe_id => $params{oe_id})
|| SL::DB::PeriodicInvoicesConfig->new(oe_id => $params{oe_id});
$obj->update_attributes(%{ $config });
}
sub _close_quotations_rfqs {
$main::lxdebug->enter_sub();
......
# delete-values
@values = (conv_i($form->{id}));
# periodic invoices and their configuration
do_query($form, $dbh, qq|DELETE FROM periodic_invoices WHERE config_id IN (SELECT id FROM periodic_invoices_configs WHERE oe_id = ?)|, @values);
do_query($form, $dbh, qq|DELETE FROM periodic_invoices_configs WHERE oe_id = ?|, @values);
# delete status entries
$query = qq|DELETE FROM status | .
qq|WHERE trans_id = ?|;
......
}
$sth->finish;
delete $form->{periodic_invoices_config};
if ($form->{id} && ($form->{type} eq 'sales_order')) {
$query = qq|SELECT periodicity, start_date, print, printer_id, copies, active, ar_chart_id FROM periodic_invoices_configs WHERE oe_id = ? LIMIT 1|;
$ref = selectfirst_hashref_query($form, $dbh, $query, conv_i($form->{id}));
$form->{periodic_invoices_config} = YAML::Dump($ref) if ($ref);
}
} else {
# get last name used
......
Common::webdav_folder($form) if ($main::webdav);
my $rc = $dbh->commit;
$dbh->disconnect;
$main::lxdebug->leave_sub();
bin/mozilla/oe.pl
use SL::MoreCommon qw(ary_diff);
use SL::PE;
use SL::ReportGenerator;
use List::MoreUtils qw(any none);
use List::Util qw(max reduce sum);
use Data::Dumper;
......
$onload .= qq|;setupPoints('|. $myconfig{numberformat} .qq|', '|. $locale->text("wrongformat") .qq|')|;
$TMPL_VAR{onload} = $onload;
if ($form->{type} eq 'sales_order') {
if (!$form->{periodic_invoices_config}) {
$form->{periodic_invoices_status} = $locale->text('not configured');
} else {
my $config = YAML::Load($form->{periodic_invoices_config});
$form->{periodic_invoices_status} = $config->{active} ? $locale->text('active') : $locale->text('inactive');
}
}
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_form_details.js"></script>|;
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_history.js"></script>|;
$form->{javascript} .= qq|<script type="text/javascript" src="js/show_vc_details.js"></script>|;
......
"salesman",
"shipvia", "globalprojectnumber",
"transaction_description", "open",
"delivered", "marge_total", "marge_percent",
"delivered", "periodic_invoices",
"marge_total", "marge_percent",
"vcnumber", "ustid",
"country",
);
......
unshift @columns, "ids";
}
$form->{l_open} = $form->{l_closed} = "Y" if ($form->{open} && $form->{closed});
$form->{l_delivered} = "Y" if ($form->{delivered} && $form->{notdelivered});
$form->{l_open} = $form->{l_closed} = "Y" if ($form->{open} && $form->{closed});
$form->{l_delivered} = "Y" if ($form->{delivered} && $form->{notdelivered});
$form->{l_periodic_invoices} = "Y" if ($form->{periodic_invoices_active} && $form->{periodic_invoices_inactive});
my $attachment_basename;
if ($form->{vc} eq 'vendor') {
......
my @hidden_variables = map { "l_${_}" } @columns;
push @hidden_variables, "l_subtotal", $form->{vc}, qw(l_closed l_notdelivered open closed delivered notdelivered ordnumber quonumber
transaction_description transdatefrom transdateto type vc employee_id salesman_id
reqdatefrom reqdateto projectnumber project_id);
reqdatefrom reqdateto projectnumber project_id periodic_invoices_active periodic_invoices_inactive);
my $href = build_std_url('action=orders', grep { $form->{$_} } @hidden_variables);
......
'vcnumber' => { 'text' => $form->{vc} eq 'customer' ? $locale->text('Customer Number') : $locale->text('Vendor Number'), },
'country' => { 'text' => $locale->text('Country'), },
'ustid' => { 'text' => $locale->text('USt-IdNr.'), },
'periodic_invoices' => { 'text' => $locale->text('Per. Inv.'), },
);
foreach my $name (qw(id transdate reqdate quonumber ordnumber name employee salesman shipvia transaction_description)) {
......
push @options, $locale->text('Closed') if $form->{closed};
push @options, $locale->text('Delivered') if $form->{delivered};
push @options, $locale->text('Not delivered') if $form->{notdelivered};
push @options, $locale->text('Periodic invoices active') if $form->{periodic_invoices_actibe};
$report->set_options('top_info_text' => join("\n", @options),
'raw_top_info_text' => $form->parse_html_template('oe/orders_top'),
......
foreach my $oe (@{ $form->{OE} }) {
map { $oe->{$_} *= $oe->{exchangerate} } @subtotal_columns;
$oe->{tax} = $oe->{amount} - $oe->{netamount};
$oe->{open} = $oe->{closed} ? $locale->text('No') : $locale->text('Yes');
$oe->{delivered} = $oe->{delivered} ? $locale->text('Yes') : $locale->text('No');
$oe->{tax} = $oe->{amount} - $oe->{netamount};
$oe->{open} = $oe->{closed} ? $locale->text('No') : $locale->text('Yes');
$oe->{delivered} = $oe->{delivered} ? $locale->text('Yes') : $locale->text('No');
$oe->{periodic_invoices} = $oe->{periodic_invoices} ? $locale->text('On') : $locale->text('Off');
map { $subtotals{$_} += $oe->{$_};
$totals{$_} += $oe->{$_} } @subtotal_columns;
......
return $content;
}
sub edit_periodic_invoices_config {
$::lxdebug->enter_sub();
$::form->{type} = 'sales_order';
check_oe_access();
my $config;
$config = YAML::Load($::form->{periodic_invoices_config}) if $::form->{periodic_invoices_config};
if ('HASH' ne ref $config) {
$config = {
periodicity => 'm',
start_date => $::form->{transdate},
active => 1,
};
}
$config->{periodicity} = 'm' if none { $_ eq $config->{periodicity} } qw(m q y);
$::form->get_lists(printers => "ALL_PRINTERS",
charts => { key => 'ALL_CHARTS',
transdate => 'current_date' });
$::form->{AR} = [ grep { $_->{link} =~ m/(?:^|:)AR(?::|$)/ } @{ $::form->{ALL_CHARTS} } ];
$::form->{title} = $::locale->text('Edit the configuration for periodic invoices');
$::form->header();
print $::form->parse_html_template('oe/edit_periodic_invoices_config', $config);
$::lxdebug->leave_sub();
}
sub save_periodic_invoices_config {
$::lxdebug->enter_sub();
$::form->{type} = 'sales_order';
check_oe_access();
$::form->isblank('start_date', $::locale->text('The start date is missing.'));
my $config = { active => $::form->{active} ? 1 : 0,
periodicity => (any { $_ eq $::form->{periodicity} } qw(m q y)) ? $::form->{periodicity} : 'm',
start_date => $::form->{start_date},
print => $::form->{print} ? 1 : 0,
printer_id => $::form->{print} ? $::form->{printer_id} * 1 : undef,
copies => $::form->{copies} * 1 ? $::form->{copies} : 1,
ar_chart_id => $::form->{ar_chart_id} * 1,
};
$::form->{periodic_invoices_config} = YAML::Dump($config);
$::form->{title} = $::locale->text('Edit the configuration for periodic invoices');
$::form->header;
print $::form->parse_html_template('oe/save_periodic_invoices_config', $config);
$::lxdebug->leave_sub();
}
sub dispatcher {
my $form = $main::form;
my $locale = $main::locale;
js/edit_periodic_invoices_config.js
function edit_periodic_invoices_config() {
var width = 750;
var height = 550;
var parm = centerParms(width, height) + ",width=" + width + ",height=" + height + ",status=yes,scrollbars=yes";
var config = $('#periodic_invoices_config').attr('value');
var transdate = $('#transdate').attr('value');
var url = "oe.pl?" +
"action=edit_periodic_invoices_config&" +
"periodic_invoices_config=" + encodeURIComponent(config) + "&" +
"transdate=" + encodeURIComponent(transdate);
// alert(url);
window.open(url, "_new_generic", parm);
}
locale/de/all
'Company Name' => 'Firmenname',
'Compare to' => 'Gegenüberstellen zu',
'Configuration of individual TODO items' => 'Konfiguration f&uuml;r die einzelnen Aufgabenlistenpunkte',
'Configure' => 'Konfigurieren',
'Confirm' => 'Best&auml;tigen',
'Confirm!' => 'Bestätigen Sie!',
'Confirmation' => 'Auftragsbestätigung',
......
'Edit rights' => 'Rechte bearbeiten',
'Edit templates' => 'Vorlagen bearbeiten',
'Edit the Delivery Order' => 'Lieferschein bearbeiten',
'Edit the configuration for periodic invoices' => 'Konfiguration für wiederkehrende Rechnungen bearbeiten',
'Edit the membership of all users in all groups:' => 'Bearbeiten der Mitgliedschaft aller Benutzer in allen Gruppen:',
'Edit the purchase_order' => 'Bearbeiten des Lieferantenauftrags',
'Edit the request_quotation' => 'Bearbeiten der Preisanfrage',
......
'Payment posted!' => 'Zahlung gebucht!',
'Payment terms deleted!' => 'Zahlungskonditionen gelöscht!',
'Payments' => 'Zahlungsausgänge',
'Per. Inv.' => 'Wied. Rech.',
'Period' => 'Zeitraum',
'Period:' => 'Zeitraum:',
'Periodic Invoices' => 'Wiederkehrende Rechnungen',
'Periodic invoices active' => 'Wiederkehrende Rechnungen aktiv',
'Periodic invoices inactive' => 'Wiederkehrende Rechnungen inaktiv',
'Periodicity' => 'Periodizität',
'Personal settings' => 'Pers&ouml;nliche Einstellungen',
'Pg Database Administration' => 'Datenbankadministration',
'Phone' => 'Telefon',
......
'Pricegroups' => 'Preisgruppen',
'Print' => 'Drucken',
'Print and Post' => 'Drucken und Buchen',
'Print automatically' => 'Automatisch ausdrucken',
'Print dunnings' => 'Mahnungen drucken',
'Print list' => 'Liste ausdrucken',
'Print options' => 'Druckoptionen',
......
'Spoolfile' => 'Druckdatei',
'Start Dunning Process' => 'Mahnprozess starten',
'Start analysis' => 'Analyse beginnen',
'Start date' => 'Startdatum',
'Start the correction assistant' => 'Korrekturassistenten starten',
'Startdate_coa' => 'Gültig ab',
'Starting Balance' => 'Eröffnungsbilanzwerte',
......
'The selected warehouse is empty.' => 'Das ausgew&auml;hlte Lager ist leer.',
'The session is invalid or has expired.' => 'Sie sind von Lx-Office abgemeldet.',
'The source warehouse does not contain any bins.' => 'Das Quelllager enth&auml;lt keine Lagerpl&auml;tze.',
'The start date is missing.' => 'Das Startdatum fehlt.',
'The subject is missing.' => 'Der Betreff fehlt.',
'The tables for user management and authentication do not exist. They will be created in the next step in the following database:' => 'Die Tabellen zum Speichern der Benutzerdaten und zur Benutzerauthentifizierung wurden nicht gefunden. Sie werden in der folgenden Datenbank angelegt:',
'The tabulator character' => 'Das Tabulator-Symbol',
......
'[email]' => '[email]',
'account_description' => 'Beschreibung',
'accrual' => 'Bilanzierung (Soll-Versteuerung)',
'active' => 'aktiv',
'all entries' => 'alle Einträge',
'ap_aging_list' => 'liste_offene_verbindlichkeiten',
'ar_aging_list' => 'liste_offene_forderungen',
......
'general_ledger_list' => 'buchungsjournal',
'history' => 'Historie',
'history search engine' => 'Historien Suchmaschine',
'inactive' => 'inaktiv',
'invoice' => 'Rechnung',
'invoice_list' => 'debitorenbuchungsliste',
'lead deleted!' => 'Kundenquelle gelöscht',
......
'mark as paid' => 'als bezahlt markieren',
'missing' => 'Fehlbestand',
'month' => 'Monatliche Abgabe',
'monthly' => 'monatlich',
'new Window' => 'neues Fenster',
'no' => 'nein',
'no bestbefore' => 'keine Mindesthaltbarkeit',
'no chargenumber' => 'keine Chargennummer',
'none (pricegroup)' => 'keine',
'not configured' => 'nicht konfiguriert',
'not executed' => 'nicht ausgeführt',
'not transferred in yet' => 'noch nicht eingelagert',
'not transferred out yet' => 'noch nicht ausgelagert',
......
'purchase_order' => 'Auftrag',
'purchase_order_list' => 'lieferantenauftragsliste',
'quarter' => 'Vierteljährliche (quartalsweise) Abgabe',
'quarterly' => 'quartalsweise',
'quotation_list' => 'angebotsliste',
'release_material' => 'Materialausgabebe',
'report_generator_dispatch_to is not defined.' => 'report_generator_dispatch_to ist nicht definiert.',
......
'warehouse_journal_list' => 'lagerbuchungsliste',
'warehouse_report_list' => 'lagerbestandsliste',
'wrongformat' => 'Falsches Format',
'yearly' => 'jährlich',
'yes' => 'ja',
};
templates/webpages/oe/edit_periodic_invoices_config.html
[% USE HTML %]
[% USE LxERP %]
[% USE L %]
<body>
<div class="listtop">[% title %]</div>
<form name="Form" action="oe.pl" method="post">
<p>
<table border="0">
<tr>
<th align="right">[%- LxERP.t8('Active') %]</th>
<td>[% L.checkbox_tag("active", checked => active) %]</td>
</tr>
<tr>
<th align="right" valign="top">[%- LxERP.t8('Periodicity') %]</th>
<td valign="top">
[% L.radio_button_tag("periodicity", value => "m", label => LxERP.t8("monthly"), checked => periodicity == 'm') %]
<br>
[% L.radio_button_tag("periodicity", value => "q", label => LxERP.t8("quarterly"), checked => periodicity == 'q') %]
<br>
[% L.radio_button_tag("periodicity", value => "y", label => LxERP.t8("yearly"), checked => periodicity == 'y') %]
</td>
</tr>
<tr>
<th align="right">[%- LxERP.t8('Start date') %]</th>
<td valign="top">
[% L.date_tag("start_date", start_date) %]
</td>
</tr>
<tr>
<th align="right">[%- LxERP.t8('Record in') %]</th>
<td valign="top">
[% L.select_tag("ar_chart_id", L.options_for_select(AR, title => 'description', default => ar_chart_id)) %]
</td>
</tr>
<tr>
<th align="right">[%- LxERP.t8('Print automatically') %]</th>
<td valign="top">
[% L.checkbox_tag("print", onclick => "toggle_printer_id_ctrl()", checked => print) %]
</td>
</tr>
<tr>
<th align="right">[%- LxERP.t8('Printer') %]</th>
<td valign="top">
[% L.select_tag("printer_id", L.options_for_select(ALL_PRINTERS, title => 'printer_description', default => printer_id), disabled => !print) %]
</td>
</tr>
<tr>
<th align="right">[%- LxERP.t8('Copies') %]</th>
<td valign="top">[% L.input_tag("copies", copies, size => 6, disabled => !print) %]</td>
</tr>
</table>
</p>
[% L.hidden_tag('action', 'save_periodic_invoices_config') %]
<p>
[% L.submit_tag('', LxERP.t8('Close')) %]
[% L.submit_tag('', LxERP.t8('Cancel'), onclick => "self.close(); return false;") %]
</p>
</form>
<script type="text/javascript">
<!--
function toggle_printer_id_ctrl() {
var disabled = !$('#print').attr('checked');
$('#printer_id').attr('disabled', disabled);
$('#copies').attr('disabled', disabled);
}
-->
</script>
</body>
</html>
templates/webpages/oe/form_footer.html
[%- USE T8 %]
[%- USE HTML %]
[%- USE LxERP %]
[%- USE L %]
<tr>
<td>
<table width="100%">
......
show_empty = 1 -%]
</td>
</tr>
[%- IF is_sales_ord %]
<tr>
<th align="right">[%- LxERP.t8('Periodic Invoices') %]</th>
<td>
[% L.button_tag("edit_periodic_invoices_config(); return false;", LxERP.t8('Configure')) %]
([% HTML.escape(periodic_invoices_status) %])
[% L.hidden_tag("periodic_invoices_config", periodic_invoices_config) %]
</td>
</tr>
[%- END %]
[%- IF id && num_follow_ups %]
<tr>
<td colspan="2">[% LxERP.t8('There are #1 unfinished follow-ups of which #2 are due.', num_follow_ups, num_due_follow_ups) %]</td>
templates/webpages/oe/form_header.html
[%- USE T8 %]
[%- USE HTML %]
[%- USE LxERP %]
[%- USE L %]
<body onLoad="[% onload %]">
<form method="post" name="oe" action="[% script %]">
......
<script type="text/javascript" src="js/calculate_qty.js"></script>
<script type="text/javascript" src="js/customer_or_vendor_selection.js"></script>
<script type="text/javascript" src="js/follow_up.js"></script>
[%- IF is_sales_ord %]
[% L.javascript_tag("js/edit_periodic_invoices_config") %]
[%- END %]
[%- FOREACH row = HIDDENS %]
<input type="hidden" name="[% HTML.escape(row.name) %]" value="[% HTML.escape(row.value) %]" >
templates/webpages/oe/save_periodic_invoices_config.html
[% USE HTML %]
[% USE L %]
<body onload="copy_values_and_close()">
<script type="text/javascript">
<!--
function copy_values_and_close() {
window.opener.document.getElementsByName("periodic_invoices_config")[0].value = $("#periodic_invoices_config").attr('value');
window.close();
}
-->
</script>
<form name="Form">
[% L.hidden_tag("periodic_invoices_config", periodic_invoices_config) %]
</form>
</body>
</html>
templates/webpages/oe/search.html
[%- USE HTML %]
[%- USE T8 %]
[%- USE LxERP %]
[%- USE L %]
[%- SET vclabel = vc == 'customer' ? LxERP.t8('Customer') : LxERP.t8('Vendor') %]
[%- SET vcnumberlabel = vc == 'customer' ? LxERP.t8('Customer Number') : LxERP.t8('Vendor Number') %]
<body>
......
<label for="delivered">[% 'Delivered' | $T8 %]</label>
</td>
</tr>
[%- END %]
[%- IF type == 'sales_order' %]
<tr>
<td>
[% L.checkbox_tag("periodic_invoices_active", label => LxERP.t8("Periodic invoices active")) %]
</td>
<td>
[% L.checkbox_tag("periodic_invoices_inactive", label => LxERP.t8("Periodic invoices inactive")) %]
</td>
</tr>
[%- END %]
<tr>
<td>

Auch abrufbar als: Unified diff