View | Details | Raw Unified | Return to bug 14973
Collapse All | Expand All

(-)a/C4/Suggestions.pm (-1 / +1 lines)
Lines 682-688 sub MarcRecordFromNewSuggestion { Link Here
682
    }
682
    }
683
    else {
683
    else {
684
        $record->append_fields(
684
        $record->append_fields(
685
            MARC::Field->new($it_tag, ' ', ' ', $it_subfield => $suggestion->{author})
685
            MARC::Field->new($it_tag, ' ', ' ', $it_subfield => $suggestion->{itemtype})
686
        );
686
        );
687
    }
687
    }
688
688
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-1 / +31 lines)
Lines 233-238 Link Here
233
[% END %]
233
[% END %]
234
234
235
[% IF ( op_save ) %]
235
[% IF ( op_save ) %]
236
    [% FOR m IN messages %]
237
        <div class="dialog [% m.type %]">
238
            [% SWITCH m.code %]
239
            [% CASE 'biblio_exists' %]
240
                A similar document already exists: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.id %]">[% m.title %]</a>. Click on "Confirm your suggestion" to ignore this message.
241
            [% CASE %]
242
                [% m.code %]
243
            [% END %]
244
        </div>
245
    [% END %]
236
    <form id="add_edit" action="suggestion.pl" method="post" class="validated">
246
    <form id="add_edit" action="suggestion.pl" method="post" class="validated">
237
    <input type="hidden" name="redirect" id="redirect" value="[% redirect | html %]" />
247
    <input type="hidden" name="redirect" id="redirect" value="[% redirect | html %]" />
238
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber | html %]" />
248
    <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% borrowernumber | html %]" />
Lines 404-410 Link Here
404
			<input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total | html %]"/>
414
			<input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total | html %]"/>
405
                </li></ol>
415
                </li></ol>
406
    </fieldset><input type="hidden" id="returnsuggested" name="returnsuggested" value="[% IF ( returnsuggestedby ) %][% returnsuggestedby | html %][% ELSE %]noone[% END %]"/>
416
    </fieldset><input type="hidden" id="returnsuggested" name="returnsuggested" value="[% IF ( returnsuggestedby ) %][% returnsuggestedby | html %][% ELSE %]noone[% END %]"/>
407
    <fieldset class="action"><input type="hidden" name="op" value="[% op | html %]" />[% IF ( suggestionid ) %]<input type="submit" value="Save" /> <a class="cancel" href="[% IF ( returnsuggestedby ) %]/cgi-bin/koha/members/moremember.pl?borrowernumber=[% returnsuggestedby | uri %]#suggestions[% ELSE %]suggestion.pl[% END %]">Cancel</a>[% ELSE %]<input type="submit" value="Submit your suggestion" /> <a class="cancel" href="suggestion.pl">Cancel</a>[% END %]
417
    <fieldset class="action">
418
        <input type="hidden" name="op" value="[% op | html %]" />
419
        [% IF ( suggestionid ) %]
420
            [% IF ( need_confirm ) %]
421
                <input type="hidden" name="save_confirmed" value="1" />
422
                <input onclick="this.form.op.value = 'save'; this.form.submit();" type="submit" value="Confirm your suggestion" />
423
            [% ELSE %]
424
                <input type="submit" value="Save" />
425
            [% END %]
426
            <a class="cancel" href="[% IF ( returnsuggestedby ) %]/cgi-bin/koha/members/moremember.pl?borrowernumber=[% returnsuggestedby | uri %]#suggestions[% ELSE %]suggestion.pl[% END %]">Cancel</a>
427
        [% ELSE %]
428
            [% IF ( need_confirm ) %]
429
                <input type="hidden" name="save_confirmed" value="1" />
430
                <input onclick="this.form.op.value = 'save'; this.form.submit();" type="submit" value="Confirm your suggestion" />
431
            [% ELSE %]
432
                <input type="submit" value="Submit your suggestion" />
433
            [% END %]
434
            <a class="cancel" href="suggestion.pl">Cancel</a>
435
        [% END %]
408
    </fieldset>
436
    </fieldset>
409
    </form>
437
    </form>
410
[% END %]
438
[% END %]
Lines 422-427 Link Here
422
        [% SWITCH m.code %]
450
        [% SWITCH m.code %]
423
        [% CASE 'already_exists' %]
451
        [% CASE 'already_exists' %]
424
            The suggestion has not been added. A suggestion with this title already exists (<a href='/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% m.id | html %]&op=show'>suggestion #[% m.id | html %]</a>)
452
            The suggestion has not been added. A suggestion with this title already exists (<a href='/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% m.id | html %]&op=show'>suggestion #[% m.id | html %]</a>)
453
        [% CASE 'biblio_exists' %]
454
            A similar document already exists: <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% m.id %]">[% m.title %]</a>. Click on "Confirm your suggestion" to ignore this message.
425
        [% CASE %]
455
        [% CASE %]
426
            [% m.code | html %]
456
            [% m.code | html %]
427
        [% END %]
457
        [% END %]
(-)a/suggestion/suggestion.pl (-40 / +59 lines)
Lines 91-96 my $returnsuggested = $input->param('returnsuggested'); Link Here
91
my $managedby       = $input->param('managedby');
91
my $managedby       = $input->param('managedby');
92
my $displayby       = $input->param('displayby') || '';
92
my $displayby       = $input->param('displayby') || '';
93
my $tabcode         = $input->param('tabcode');
93
my $tabcode         = $input->param('tabcode');
94
my $save_confirmed  = $input->param('save_confirmed') || 0;
95
94
my $reasonsloop     = GetAuthorisedValues("SUGGEST");
96
my $reasonsloop     = GetAuthorisedValues("SUGGEST");
95
97
96
# filter informations which are not suggestion related.
98
# filter informations which are not suggestion related.
Lines 121-177 $template->param('borrowernumber' => $borrowernumber); Link Here
121
#########################################
123
#########################################
122
##  Operations
124
##  Operations
123
##
125
##
126
124
if ( $op =~ /save/i ) {
127
if ( $op =~ /save/i ) {
125
    $suggestion_only->{suggesteddate} = dt_from_string( $suggestion_only->{suggesteddate} )
128
    my @messages;
126
        if $suggestion_only->{suggesteddate};
129
    my $biblio = MarcRecordFromNewSuggestion({
130
            title => $suggestion_only->{title},
131
            author => $suggestion_only->{author},
132
            itemtype => $suggestion_only->{itemtype},
133
    });
134
135
    if ( ( my ($duplicatebiblionumber, $duplicatetitle) = FindDuplicate($biblio) ) && !$save_confirmed ) {
136
        push @messages, { type => 'error', code => 'biblio_exists', id => $duplicatebiblionumber, title => $duplicatetitle }; 
137
        $template->param(
138
            messages => \@messages,
139
            need_confirm => 1
140
        );
141
        delete $suggestion_ref->{suggesteddate};
142
        Init($suggestion_ref);
143
    }
144
    else {
145
        $suggestion_only->{suggesteddate} = dt_from_string( $suggestion_only->{suggesteddate} )
146
            if $suggestion_only->{suggesteddate};
127
147
128
    if ( $suggestion_only->{"STATUS"} ) {
148
        if ( $suggestion_only->{"STATUS"} ) {
129
        if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
149
            if ( my $tmpstatus = lc( $suggestion_only->{"STATUS"} ) =~ /ACCEPTED|REJECTED/i ) {
130
            $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string;
150
                $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "date" } = dt_from_string;
131
            $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" }   = C4::Context->userenv->{number};
151
                $suggestion_only->{ lc( $suggestion_only->{"STATUS"}) . "by" }   = C4::Context->userenv->{number};
152
            }
153
            $suggestion_only->{manageddate} = dt_from_string;
154
            $suggestion_only->{"managedby"}   = C4::Context->userenv->{number};
132
        }
155
        }
133
        $suggestion_only->{manageddate} = dt_from_string;
134
        $suggestion_only->{"managedby"}   = C4::Context->userenv->{number};
135
    }
136
156
137
    my $otherreason = $input->param('other_reason');
157
        my $otherreason = $input->param('other_reason');
138
    if ($suggestion_only->{reason} eq 'other' && $otherreason) {
158
        if ($suggestion_only->{reason} eq 'other' && $otherreason) {
139
        $suggestion_only->{reason} = $otherreason;
159
            $suggestion_only->{reason} = $otherreason;
140
    }
160
        }
141
161
142
    if ( $suggestion_only->{'suggestionid'} > 0 ) {
162
        if ( $suggestion_only->{'suggestionid'} > 0 ) {
143
        &ModSuggestion($suggestion_only);
163
            &ModSuggestion($suggestion_only);
144
    } else {
164
        } else {
145
        ###FIXME:Search here if suggestion already exists.
165
            ###FIXME:Search here if suggestion already exists.
146
        my $suggestions_loop =
166
            my $suggestions_loop =
147
            SearchSuggestion( $suggestion_only );
167
                SearchSuggestion( $suggestion_only );
148
        if (@$suggestions_loop>=1){
168
            if (@$suggestions_loop>=1){
149
            #some suggestion are answering the request Donot Add
169
                #some suggestion are answering the request Donot Add
150
            my @messages;
170
                my @messages;
151
            for my $suggestion ( @$suggestions_loop ) {
171
                for my $suggestion ( @$suggestions_loop ) {
152
                push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
172
                    push @messages, { type => 'error', code => 'already_exists', id => $suggestion->{suggestionid} };
173
                }
174
                $template->param( messages => \@messages );
175
            } 
176
            else {    
177
                ## Adding some informations related to suggestion
178
                &NewSuggestion($suggestion_only);
153
            }
179
            }
154
            $template->param( messages => \@messages );
180
            # empty fields, to avoid filter in "SearchSuggestion"
155
        } 
181
        }  
156
        else {    
182
        map{delete $$suggestion_ref{$_}} keys %$suggestion_ref;
157
            ## Adding some informations related to suggestion
183
        $op = 'else';
158
            &NewSuggestion($suggestion_only);
159
        }
160
        # empty fields, to avoid filter in "SearchSuggestion"
161
    }  
162
    map{delete $$suggestion_ref{$_}} keys %$suggestion_ref;
163
    $op = 'else';
164
184
165
    if( $redirect eq 'purchase_suggestions' ) {
185
        if( $redirect eq 'purchase_suggestions' ) {
166
        print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber");
186
            print $input->redirect("/cgi-bin/koha/members/purchase-suggestions.pl?borrowernumber=$borrowernumber");
187
        }
167
    }
188
    }
168
169
}
189
}
170
elsif ($op=~/add/) {
190
elsif ($op=~/add/) {
171
    #Adds suggestion  
191
    #Adds suggestion
172
    Init($suggestion_ref);
192
    Init($suggestion_ref);
173
    $op ='save';
193
    $op ='save';
174
} 
194
}
175
elsif ($op=~/edit/) {
195
elsif ($op=~/edit/) {
176
    #Edit suggestion  
196
    #Edit suggestion  
177
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
197
    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
178
- 

Return to bug 14973