use List::Util qw(sum);
use SL::DB::Order;
+use SL::DB::ProjectType;
use SL::Controller::Helper::GetModels;
use SL::Controller::Helper::Paginated;
use SL::Controller::Helper::Sorted;
customer => t8('Customer'),
transaction_description => t8('Transaction description'),
globalprojectnumber => t8('Project'),
+ globalproject_type => t8('Project Type'),
netamount => t8('Order amount'),
);
my ($self) = @_;
$self->{filter} = {};
- my %args = ( parse_filter($::form->{filter}, with_objects => [ 'customer', 'globalproject' ], launder_to => $self->{filter}));
+ my %args = ( parse_filter($::form->{filter}, with_objects => [ 'customer', 'globalproject', 'globalproject.project_type' ], launder_to => $self->{filter}));
$args{query} = [
@{ $args{query} || [] },
SL::DB::Manager::Order->type_filter('sales_order'),
my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
$self->{report} = $report;
- my @columns = qw(customer globalprojectnumber project_type ordnumber netamount delivered_amount delivered_amount_p billed_amount billed_amount_p paid_amount paid_amount_p
+ my @columns = qw(customer globalprojectnumber globalproject_type ordnumber netamount delivered_amount delivered_amount_p billed_amount billed_amount_p paid_amount paid_amount_p
billable_amount billable_amount_p other_amount);
- my @sortable = qw(ordnumber transdate customer netamount globalprojectnumber);
+ my @sortable = qw(ordnumber transdate customer netamount globalprojectnumber globalproject_type);
$self->{number_columns} = [ qw(netamount billed_amount billed_amount_p delivered_amount delivered_amount_p paid_amount paid_amount_p other_amount billable_amount billable_amount_p) ];
my %column_defs = (
customer => { sub => sub { $_[0]->customer->name },
obj_link => sub { $self->link_to($_[0]->customer) } },
globalprojectnumber => { sub => sub { $_[0]->globalproject_id ? $_[0]->globalproject->projectnumber : '' } },
- project_type => { text => $::locale->text('Project type'),
- sub => sub { $_[0]->globalproject_id ? $_[0]->globalproject->type : '' } },
+ globalproject_type => { text => $::locale->text('Project type'),
+ sub => sub { $_[0]->globalproject_id ? $_[0]->globalproject->project_type->description : '' } },
);
map { $column_defs{$_}->{text} ||= $::locale->text( $self->get_sort_spec->{$_}->{title} ) } keys %column_defs;
use SL::DB::Order;
use SL::DB::Project;
use SL::DB::PurchaseInvoice;
+use SL::DB::ProjectType;
use SL::Helper::Flash;
use SL::Locale::String;
);
__PACKAGE__->run_before('check_auth');
-__PACKAGE__->run_before('load_project', only => [ qw(edit update destroy) ]);
+__PACKAGE__->run_before('load_project', only => [ qw(edit update destroy) ]);
#
# actions
my %params;
- $params{CUSTOM_VARIABLES} = CVar->get_configs(module => 'Projects');
+ $params{ALL_PROJECT_TYPES} = SL::DB::Manager::ProjectType->get_all_sorted;
+ $params{CUSTOM_VARIABLES} = CVar->get_configs(module => 'Projects');
($params{CUSTOM_VARIABLES_FILTER_CODE}, $params{CUSTOM_VARIABLES_INCLUSION_CODE})
= CVar->render_search_options(variables => $params{CUSTOM_VARIABLES},
include_prefix => 'l_',
sub display_form {
my ($self, %params) = @_;
- $params{ALL_CUSTOMERS} = SL::DB::Manager::Customer->get_all_sorted(where => [ or => [ obsolete => 0, obsolete => undef, id => $self->project->customer_id ]]);
- $params{CUSTOM_VARIABLES} = CVar->get_custom_variables(module => 'Projects', trans_id => $self->project->id);
+ $params{ALL_CUSTOMERS} = SL::DB::Manager::Customer->get_all_sorted(where => [ or => [ obsolete => 0, obsolete => undef, id => $self->project->customer_id ]]);
+ $params{ALL_PROJECT_TYPES} = SL::DB::Manager::ProjectType->get_all_sorted;
+ $params{CUSTOM_VARIABLES} = CVar->get_custom_variables(module => 'Projects', trans_id => $self->project->id);
CVar->render_inputs(variables => $params{CUSTOM_VARIABLES}) if @{ $params{CUSTOM_VARIABLES} };
$self->render('project/form', %params);
$self->{filter} = {};
my %args = parse_filter(
$self->_pre_parse_filter($::form->{filter}, $self->{filter}),
- with_objects => [ 'customer' ],
+ with_objects => [ 'customer', 'project_type' ],
launder_to => $self->{filter},
);
my $report = SL::ReportGenerator->new(\%::myconfig, $::form);
$self->{report} = $report;
- my @columns = qw(projectnumber description customer active valid type);
- my @sortable = qw(projectnumber description customer type);
+ my @columns = qw(projectnumber description customer active valid project_type);
+ my @sortable = qw(projectnumber description customer project_type);
my %column_defs = (
projectnumber => { obj_link => sub { $self->url_for(action => 'edit', id => $_[0]->id, callback => $callback) } },
description => { obj_link => sub { $self->url_for(action => 'edit', id => $_[0]->id, callback => $callback) } },
- type => { },
+ project_type => { sub => sub { $_[0]->project_type->description } },
customer => { sub => sub { $_[0]->customer ? $_[0]->customer->name : '' } },
active => { sub => sub { $_[0]->active ? $::locale->text('Active') : $::locale->text('Inactive') },
text => $::locale->text('Active') },
customer => t8('Customer'),
description => t8('Description'),
projectnumber => t8('Project Number'),
- type => t8('Type'),
+ project_type => t8('Project Type'),
},
with_objects => [ 'customer' ],
);
--- /dev/null
+package SL::Controller::ProjectType;
+
+use strict;
+
+use parent qw(SL::Controller::Base);
+
+use SL::DB::ProjectType;
+use SL::Helper::Flash;
+
+use Rose::Object::MakeMethods::Generic
+(
+ scalar => [ qw(project_type) ],
+);
+
+__PACKAGE__->run_before('check_auth');
+__PACKAGE__->run_before('load_project_type', only => [ qw(edit update destroy) ]);
+
+#
+# actions
+#
+
+sub action_list {
+ my ($self) = @_;
+
+ $self->render('project_type/list',
+ title => $::locale->text('Project Types'),
+ PROJECT_TYPES => SL::DB::Manager::ProjectType->get_all_sorted);
+}
+
+sub action_new {
+ my ($self) = @_;
+
+ $self->{project_type} = SL::DB::ProjectType->new;
+ $self->render('project_type/form', title => $::locale->text('Create a new project type'));
+}
+
+sub action_edit {
+ my ($self) = @_;
+ $self->render('project_type/form', title => $::locale->text('Edit project type'));
+}
+
+sub action_create {
+ my ($self) = @_;
+
+ $self->{project_type} = SL::DB::ProjectType->new;
+ $self->create_or_update;
+}
+
+sub action_update {
+ my ($self) = @_;
+ $self->create_or_update;
+}
+
+sub action_destroy {
+ my ($self) = @_;
+
+ if (eval { $self->{project_type}->delete; 1; }) {
+ flash_later('info', $::locale->text('The project type has been deleted.'));
+ } else {
+ flash_later('error', $::locale->text('The project type is in use and cannot be deleted.'));
+ }
+
+ $self->redirect_to(action => 'list');
+}
+
+sub action_reorder {
+ my ($self) = @_;
+
+ my @ids = @{ $::form->{project_type_id} || [] };
+ my $result = SL::DB::ProjectType->new->db->do_transaction(sub {
+ foreach my $idx (0 .. scalar(@ids) - 1) {
+ SL::DB::ProjectType->new(id => $ids[$idx])->load->update_attributes(position => $idx + 1);
+ }
+ });
+
+ $self->render('1;', { type => 'js', inline => 1 });
+}
+
+#
+# filters
+#
+
+sub check_auth {
+ $::auth->assert('config');
+}
+
+#
+# helpers
+#
+
+sub create_or_update {
+ my $self = shift;
+ my $is_new = !$self->{project_type}->id;
+ my $params = delete($::form->{project_type}) || { };
+
+ $self->{project_type}->assign_attributes(%{ $params });
+
+ my @errors = $self->{project_type}->validate;
+
+ if (@errors) {
+ flash('error', @errors);
+ $self->render('project_type/form', title => $is_new ? $::locale->text('Create a new project type') : $::locale->text('Edit project type'));
+ return;
+ }
+
+ $self->{project_type}->save;
+
+ flash_later('info', $is_new ? $::locale->text('The project type has been created.') : $::locale->text('The project type has been saved.'));
+ $self->redirect_to(action => 'list');
+}
+
+sub load_project_type {
+ my ($self) = @_;
+ $self->{project_type} = SL::DB::ProjectType->new(id => $::form->{id})->load;
+}
+
+1;
use SL::DB::Price;
use SL::DB::Printer;
use SL::DB::Project;
+use SL::DB::ProjectType;
use SL::DB::PurchaseInvoice;
use SL::DB::RecordLink;
use SL::DB::SchemaInfo;
pricegroup => 'pricegroup',
printers => 'printer',
project => 'project',
+ project_types => 'ProjectType',
record_links => 'record_link',
sepa_export => 'sepa_export',
sepa_export_items => 'sepa_export_item',
customer => 'customer.name',
vendor => 'vendor.name',
globalprojectnumber => 'lower(globalproject.projectnumber)',
+
+ # Bug in Rose::DB::Object: the next should be
+ # "globalproject.project_type.description". This workaround will
+ # only work if no other table with "project_type" is visible in
+ # the current query
+ globalproject_type => 'lower(project_type.description)',
+
map { ( $_ => "lower(oe.$_)" ) } qw(ordnumber quonumber cusordnumber shippingpoint shipvia notes intnotes transaction_description),
});
}
sub _sort_spec {
return (
- default => [ 'projectnumber', 1 ],
- columns => {
- SIMPLE => 'ALL',
- customer => 'customer.name',
+ default => [ 'projectnumber', 1 ],
+ columns => {
+ SIMPLE => 'ALL',
+ customer => 'customer.name',
+ project_type => 'project_type.description',
});
}
--- /dev/null
+package SL::DB::Manager::ProjectType;
+
+use strict;
+
+use parent qw(SL::DB::Helper::Manager);
+
+use SL::DB::Helper::Paginated;
+use SL::DB::Helper::Sorted;
+
+sub object_class { 'SL::DB::ProjectType' }
+
+__PACKAGE__->make_manager_methods;
+
+sub _sort_spec {
+ return (
+ default => [ 'position', 1 ],
+ columns => {
+ SIMPLE => 'ALL',
+ description => 'lower(project_types.description)',
+ });
+}
+
+1;
+__END__
+
+=pod
+
+=encoding utf8
+
+=head1 NAME
+
+SL::DB::Manager::ProjectType - Manager for models for the 'project_types' table
+
+=head1 SYNOPSIS
+
+This is a standard Rose::DB::Manager based model manager and can be
+used as such.
+
+=head1 FUNCTIONS
+
+None yet.
+
+=head1 BUGS
+
+Nothing here yet.
+
+=head1 AUTHOR
+
+Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>
+
+=cut
__PACKAGE__->meta->table('project');
__PACKAGE__->meta->columns(
- active => { type => 'boolean', default => 'true' },
- customer_id => { type => 'integer' },
- description => { type => 'text' },
- id => { type => 'integer', not_null => 1, sequence => 'id' },
- itime => { type => 'timestamp', default => 'now()' },
- mtime => { type => 'timestamp' },
- projectnumber => { type => 'text' },
- type => { type => 'text' },
- valid => { type => 'boolean', default => 'true' },
+ active => { type => 'boolean', default => 'true' },
+ customer_id => { type => 'integer' },
+ description => { type => 'text' },
+ id => { type => 'integer', not_null => 1, sequence => 'id' },
+ itime => { type => 'timestamp', default => 'now()' },
+ mtime => { type => 'timestamp' },
+ project_type_id => { type => 'integer', not_null => 1 },
+ projectnumber => { type => 'text' },
+ type => { type => 'text' },
+ valid => { type => 'boolean', default => 'true' },
);
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
class => 'SL::DB::Customer',
key_columns => { customer_id => 'id' },
},
+
+ project_type => {
+ class => 'SL::DB::ProjectType',
+ key_columns => { project_type_id => 'id' },
+ },
);
1;
--- /dev/null
+# This file has been auto-generated. Do not modify it; it will be overwritten
+# by rose_auto_create_model.pl automatically.
+package SL::DB::ProjectType;
+
+use strict;
+
+use base qw(SL::DB::Object);
+
+__PACKAGE__->meta->setup(
+ table => 'project_types',
+
+ columns => [
+ id => { type => 'serial', not_null => 1 },
+ position => { type => 'integer', not_null => 1 },
+ description => { type => 'text' },
+ ],
+
+ primary_key_columns => [ 'id' ],
+);
+
+1;
+;
--- /dev/null
+package SL::DB::ProjectType;
+
+use strict;
+
+use SL::DB::MetaSetup::ProjectType;
+use SL::DB::Manager::ProjectType;
+
+use SL::DB::Helper::ActsAsList;
+
+__PACKAGE__->meta->add_relationship(
+ projects => {
+ type => 'many to one',
+ class => 'SL::DB::Project',
+ column_map => { id => 'project_type_id' },
+ },
+);
+
+__PACKAGE__->meta->initialize;
+
+sub validate {
+ my ($self) = @_;
+
+ my @errors;
+ push @errors, $::locale->text('The description is missing.') if !$self->description;
+
+ return @errors;
+}
+
+1;
'Create a new payment term' => 'Neue Zahlungsbedingungen anlegen',
'Create a new printer' => 'Einen neuen Drucker anlegen',
'Create a new project' => 'Neues Projekt anlegen',
+ 'Create a new project type' => 'Einen neuen Projekttypen anlegen',
'Create a new user' => 'Einen neuen Benutzer anlegen',
'Create a new user group' => 'Eine neue Benutzergruppe erfassen',
+ 'Create a standard group' => 'Eine Standard-Benutzergruppe anlegen',
'Create and edit RFQs' => 'Lieferantenanfragen erfassen und bearbeiten',
'Create and edit dunnings' => 'Mahnungen erfassen und bearbeiten',
'Create and edit invoices and credit notes' => 'Rechnungen und Gutschriften erfassen und bearbeiten',
'Create new department' => 'Neue Abteilung erfassen',
'Create new payment term' => 'Neue Zahlungsbedingung anlegen',
'Create new templates from master templates' => 'Neue Druckvorlagen aus Vorlagensatz erstellen',
+ 'Create new project type' => 'Neuen Projekttypen anlegen',
'Create tables' => 'Tabellen anlegen',
'Created by' => 'Erstellt von',
'Created for' => 'Erstellt für',
'Edit prices and discount (if not used, textfield is ONLY set readonly)' => 'Preise und Rabatt in Formularen frei anpassen (falls deaktiviert, wird allerdings NUR das textfield auf READONLY gesetzt / kann je nach Browserversion und technischen Fähigkeiten des Anwenders noch umgangen werden)',
'Edit project' => 'Projekt bearbeiten',
'Edit project #1' => 'Projekt #1 bearbeiten',
+ 'Edit project type' => 'Projekttypen bearbeiten',
'Edit templates' => 'Vorlagen bearbeiten',
'Edit the Delivery Order' => 'Lieferschein bearbeiten',
'Edit the configuration for periodic invoices' => 'Konfiguration für wiederkehrende Rechnungen bearbeiten',
'No print templates have been created for this client yet. Please do so in the client configuration.' => 'Für diesen Mandanten wurden noch keine Druckvorlagen angelegt. Bitte holen Sie dies in der Mandantenkonfiguration nach.',
'No printers have been created yet.' => 'Es wurden noch keine Drucker angelegt.',
'No problems were recognized.' => 'Es wurden keine Probleme gefunden.',
+ 'No project type has been created yet.' => 'Es wurden noch keine Projekttypen angelegt.',
'No report with id #1' => 'Es gibt keinen Report mit der Id #1',
'No shipto selected to delete' => 'Keine Lieferadresse zum Löschen ausgewählt',
'No summary account' => 'Kein Sammelkonto',
'Project Number' => 'Projektnummer',
'Project Numbers' => 'Projektnummern',
'Project Transactions' => 'Projektbuchungen',
+ 'Project Type' => 'Projekttyp',
+ 'Project Types' => 'Projekttypen',
'Project type' => 'Projekttyp',
'Projects' => 'Projekte',
'Projecttransactions' => 'Projektbuchungen',
'The project is in use and cannot be deleted.' => 'Das Projekt ist in Verwendung und kann nicht gelöscht werden.',
'The project number is already in use.' => 'Die Projektnummer wird bereits verwendet.',
'The project number is missing.' => 'Die Projektnummer fehlt.',
+ 'The project type has been created.' => 'Der Projekttyp wurde angelegt.',
+ 'The project type has been deleted.' => 'Der Projekttyp wurde gelöscht.',
+ 'The project type has been saved.' => 'Der Projekttyp wurde gespeichert.',
+ 'The project type is in use and cannot be deleted.' => 'Der Projekttyp wird verwendet und kann nicht gelöscht werden.',
'The second reason is that kivitendo allowed the user to enter the tax amount manually regardless of the taxkey used.' => 'Der zweite Grund war, dass kivitendo zuließ, dass die Benutzer beliebige, von den tatsächlichen Steuerschlüsseln unabhängige Steuerbeträge eintrugen.',
'The second way is to use Perl\'s CPAN module and let it download and install the module for you.' => 'Die zweite Variante besteht darin, Perls CPAN-Modul zu benutzen und es das Modul für Sie installieren zu lassen.',
'The selected bank account does not exist anymore.' => 'Das ausgewählte Bankkonto existiert nicht mehr.',
module=am.pl
action=list_lead
+[System--Project Types]
+module=controller.pl
+action=ProjectType/list
+
[System--Languages and translations]
module=menu.pl
action=acc_menu
--- /dev/null
+-- @tag: project_types
+-- @description: Tabelle für Projekttypen
+-- @depends: release_3_0_0
+-- @charset: utf-8
+CREATE TABLE project_types (
+ id SERIAL,
+ position INTEGER NOT NULL,
+ description TEXT,
+
+ PRIMARY KEY (id)
+);
+
+INSERT INTO project_types (position, description) VALUES (1, 'Standard');
+INSERT INTO project_types (position, description) VALUES (2, 'Festpreis');
+INSERT INTO project_types (position, description) VALUES (3, 'Support');
+
+ALTER TABLE project ADD COLUMN project_type_id INTEGER;
+ALTER TABLE project ADD FOREIGN KEY (project_type_id) REFERENCES project_types (id);
+
+UPDATE project SET project_type_id = (SELECT id FROM project_types WHERE description = 'Festpreis') WHERE type = 'Festpreis';
+UPDATE project SET project_type_id = (SELECT id FROM project_types WHERE description = 'Support') WHERE type = 'Support';
+UPDATE project SET project_type_id = (SELECT id FROM project_types WHERE description = 'Standard') WHERE project_type_id IS NULL;
+
+ALTER TABLE project ALTER COLUMN project_type_id SET NOT NULL;
+ALTER TABLE project DROP COLUMN type;
</tr>
<tr>
- <th align="right">[% 'Type' | $T8 %]</th>
- <td>[% L.input_tag('project.type', SELF.project.type, size=60) %]</td>
+ <th align="right">[% 'Project Type' | $T8 %]</th>
+ <td>[% L.select_tag('project.project_type_id', ALL_PROJECT_TYPES, default=SELF.project.project_type_id, title_key='description', style='width: 300px') %]</td>
</tr>
<tr>
</tr>
<tr>
- <th align="right">[% 'Type' | $T8 %]</th>
- <td>[% L.input_tag('filter.type:substr::ilike', filter.type_substr__ilike, size=20) %]</td>
+ <th align="right">[% 'Project Type' | $T8 %]</th>
+ <td>[% L.select_tag('filter.project_type_id', ALL_PROJECT_TYPES, default=filter.project_type_id, title_key='description', with_empty=1) %]</td>
</tr>
[% CUSTOM_VARIABLES_FILTER_CODE %]
--- /dev/null
+[% USE HTML %][% USE L %][% USE LxERP %]
+
+ <form method="post" action="controller.pl">
+ <div class="listtop">[% FORM.title %]</div>
+
+[%- INCLUDE 'common/flash.html' %]
+
+ <table>
+ <tr>
+ <td>[% LxERP.t8('Description') %]</td>
+ <td>[% L.input_tag("project_type.description" SELF.project_type.description) %]</td>
+ </tr>
+ </table>
+
+ <p>
+ [% L.hidden_tag("id", SELF.project_type.id) %]
+ [% L.hidden_tag("action", "ProjectType/dispatch") %]
+ [% L.submit_tag("action_" _ (SELF.project_type.id ? 'update' : 'create'), LxERP.t8('Save')) %]
+ [%- IF SELF.project_type.id %]
+ [% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Do you really want to delete this object?')) %]
+ [%- END %]
+ <a href="[% SELF.url_for(action => 'list') %]">[% LxERP.t8('Abort') %]</a>
+ </p>
+
+ </form>
--- /dev/null
+[% USE HTML %][% USE T8 %][% USE L %][% USE LxERP %]
+
+ <div class="listtop">[% FORM.title %]</div>
+
+[%- INCLUDE 'common/flash.html' %]
+
+ <form method="post" action="controller.pl">
+ [% IF !PROJECT_TYPES.size %]
+ <p>
+ [%- 'No project type has been created yet.' | $T8 %]
+ </p>
+
+ [%- ELSE %]
+ <table id="project_type_list">
+ <thead>
+ <tr class="listheading">
+ <th align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></th>
+ <th>[%- 'Description' | $T8 %]</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ [%- FOREACH project_type = PROJECT_TYPES %]
+ <tr class="listrow[% loop.count % 2 %]" id="project_type_id_[% project_type.id %]">
+ <td align="center" class="dragdrop"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
+ <td>
+ <a href="[% SELF.url_for(action => 'edit', id => project_type.id) %]">
+ [%- HTML.escape(project_type.description) %]
+ </a>
+ </td>
+ </tr>
+ [%- END %]
+ </tbody>
+ </table>
+ [%- END %]
+
+ <p>
+ <a href="[% SELF.url_for(action => 'new') %]">[%- 'Create new project type' | $T8 %]</a>
+ </p>
+ </form>
+
+ [% L.sortable_element('#project_type_list tbody', url => 'controller.pl?action=ProjectType/reorder', with => 'project_type_id') %]