@@ -, +, @@ suggestions.orderedby --- C4/Suggestions.pm | 7 +++++++ ...13392-add-suggestions-ordereddate-and-suggestions-orderedby.sql | 4 ++++ installer/data/mysql/kohastructure.sql | 3 +++ koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt | 5 +++++ suggestion/suggestion.pl | 2 +- 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/Bug-13392-add-suggestions-ordereddate-and-suggestions-orderedby.sql --- a/C4/Suggestions.pm +++ a/C4/Suggestions.pm @@ -491,6 +491,13 @@ sub ModSuggestion { or $suggestion->{$field} eq '' ); } + if ($suggestion->{STATUS} and $suggestion->{STATUS} eq 'ORDERED') { + $suggestion->{ordereddate} = dt_from_string; + if (C4::Context->userenv) { + $suggestion->{orderedby} = C4::Context->userenv->{number}; + } + } + my $rs = Koha::Database->new->schema->resultset('Suggestion')->find($suggestion->{suggestionid}); my $status_update_table = 1; eval { --- a/installer/data/mysql/atomicupdate/Bug-13392-add-suggestions-ordereddate-and-suggestions-orderedby.sql +++ a/installer/data/mysql/atomicupdate/Bug-13392-add-suggestions-ordereddate-and-suggestions-orderedby.sql @@ -0,0 +1,4 @@ +ALTER TABLE suggestions +ADD COLUMN orderedby INT(11) NULL DEFAULT NULL AFTER rejecteddate, +ADD COLUMN ordereddate DATE NULL DEFAULT NULL AFTER orderedby, +ADD CONSTRAINT suggestions_orderedby_fk FOREIGN KEY (orderedby) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE; --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -3029,6 +3029,8 @@ CREATE TABLE `suggestions` ( -- purchase suggestions accepteddate date default NULL, -- date the suggestion was marked as accepted rejectedby INT(11) default NULL, -- borrowernumber for the librarian who rejected the suggestion, foreign key linking to the borrowers table rejecteddate date default NULL, -- date the suggestion was marked as rejected + orderedby INT(11) NULL DEFAULT NULL, -- borrowernumber for the librarian who ordered the suggestion + ordereddate DATE NULL DEFAULT NULL, -- date the suggestion was marked as ordered `STATUS` varchar(10) NOT NULL default '', -- suggestion status (ASKED, CHECKED, ACCEPTED, or REJECTED) `note` mediumtext, -- note entered on the suggestion `author` varchar(80) default NULL, -- author of the suggested item @@ -3058,6 +3060,7 @@ CREATE TABLE `suggestions` ( -- purchase suggestions KEY `biblionumber` (`biblionumber`), KEY `branchcode` (`branchcode`), CONSTRAINT `suggestions_budget_id_fk` FOREIGN KEY (`budgetid`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE + CONSTRAINT suggestions_orderedby_fk FOREIGN KEY (orderedby) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -320,6 +320,11 @@ h4.local_collapse a { font-size : 80%; text-decoration: none; } fieldset.brief o [% accepteddate | $KohaDates %] [% IF ( acceptedby_borrowernumber ) %][% acceptedby_surname %], [% acceptedby_firstname %] [% Branches.GetName( acceptedby_branchcode ) %] ([% acceptedby_description %])[% END %] + + Suggestion ordered + [% ordereddate | $KohaDates %] + [% IF ( orderedby_borrowernumber ) %][% orderedby_surname %], [% orderedby_firstname %] [% Branches.GetName( orderedby_branchcode ) %] ([% orderedby_description %])[% END %] + --- a/suggestion/suggestion.pl +++ a/suggestion/suggestion.pl @@ -278,7 +278,7 @@ if ($op=~/else/) { ); } -foreach my $element ( qw(managedby suggestedby acceptedby) ) { +foreach my $element ( qw(managedby suggestedby acceptedby orderedby) ) { # $debug || warn $$suggestion_ref{$element}; if ($$suggestion_ref{$element}){ my $member=GetMember(borrowernumber=>$$suggestion_ref{$element}); --