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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt (-7 / +30 lines)
Lines 29-37 Link Here
29
                            <h1>Enter a new purchase suggestion</h1>
29
                            <h1>Enter a new purchase suggestion</h1>
30
30
31
                            <p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion</p>
31
                            <p>Please fill out this form to make a purchase suggestion. You will receive an email when the library processes your suggestion</p>
32
                            <p>Only the title is required, but the more information you enter the easier it will be for the librarians to find the title you're requesting. The "Notes" field can be used to provide any additional information.</p>
32
                            [% IF (mandatoryfields) %]
33
                            <p>Form fields labeled in red are mandatory. The more information you enter the easier it will be for the librarians to find the title you're requesting.
34
                            [% ELSE %]
35
                            <p>Only the title is required, but the more information you enter the easier it will be for the librarians to find the title you're requesting.
36
                            [% END %]
37
                            The "Notes" field can be used to provide any additional information.</p>
33
38
34
                            <form action="/cgi-bin/koha/opac-suggestions.pl" method="post">
39
                            <form action="/cgi-bin/koha/opac-suggestions.pl" id="newsuggestionform" onsubmit="return Check(this);" method="post">
35
                                <fieldset class="rows">
40
                                <fieldset class="rows">
36
                                    <ol>
41
                                    <ol>
37
                                        <li><label class="required" for="title">Title:</label><input type="text" id="title" name="title"  maxlength="255" /></li>
42
                                        <li><label class="required" for="title">Title:</label><input type="text" id="title" name="title"  maxlength="255" /></li>
Lines 94-100 Link Here
94
                                <fieldset class="action">
99
                                <fieldset class="action">
95
                                    <input type="hidden" name="suggestedby" value="[% suggestedbyme %]" />
100
                                    <input type="hidden" name="suggestedby" value="[% suggestedbyme %]" />
96
                                    <input type="hidden" name="op" value="add_confirm" />
101
                                    <input type="hidden" name="op" value="add_confirm" />
97
                                    <input type="submit" onclick="Check(this.form); return false;" class="btn" value="Submit your suggestion" /> <a class="action" href="/cgi-bin/koha/opac-suggestions.pl">Cancel</a>
102
                                    <input type="submit" class="btn" value="Submit your suggestion" /> <a class="action" href="/cgi-bin/koha/opac-suggestions.pl">Cancel</a>
98
                                </fieldset>
103
                                </fieldset>
99
                            </form>
104
                            </form>
100
                        [% END #  IF op_add %]
105
                        [% END #  IF op_add %]
Lines 304-326 Link Here
304
          return true;
309
          return true;
305
        });
310
        });
306
        [% END %]
311
        [% END %]
312
        [% IF ( op_add && mandatoryfields ) %]
313
        var FldsRequired = [[% mandatoryfields %]];
314
        for (var i = 0; i < FldsRequired.length; i++) {
315
            var rqinput = $('#' + FldsRequired[i]);
316
            if (rqinput.length != 1) continue;
317
            $(rqinput).attr("required", "required");
318
            var rqlabel = $("label[for=" + rqinput.attr("id") + "]");
319
            if (rqlabel.length != 1) continue;
320
            $(rqlabel).addClass('required');
321
        }
322
        [% END %]
307
    });
323
    });
308
324
309
    function Check(f) {
325
    function Check(f) {
310
        var _alertString="";
326
        var _alertString="";
311
        var alertString2;
327
        var alertString2;
312
328
313
        if(f.title.value.length ==0){
329
        var FieldsRequired = [[% mandatoryfields %]];
314
            _alertString += _("- You must enter a Title") + "\n";
330
        FieldsRequired.unshift("title");
331
332
        for (var i = 0; i < FieldsRequired.length; i++) {
333
            var lbl = FieldsRequired[i];
334
            if (!f[lbl] || (f[lbl].value.length != 0)) continue;
335
            _alertString += _("- Some mandatory fields are missing") + "\n";
336
            break;
315
        }
337
        }
316
338
317
        if (_alertString.length==0) {
339
        if (_alertString.length == 0) {
318
            f.submit();
340
            return true;
319
        } else {
341
        } else {
320
            alertString2 = _("Form not submitted because of the following problem(s)");
342
            alertString2 = _("Form not submitted because of the following problem(s)");
321
            alertString2 += "\n------------------------------------------------------------------------------------\n\n";
343
            alertString2 += "\n------------------------------------------------------------------------------------\n\n";
322
            alertString2 += _alertString;
344
            alertString2 += _alertString;
323
            alert(alertString2);
345
            alert(alertString2);
346
            return false;
324
        }
347
        }
325
    }
348
    }
326
//]]>
349
//]]>
(-)a/opac/opac-suggestions.pl (-1 / +17 lines)
Lines 153-158 if ( C4::Context->preference("AllowPurchaseSuggestionBranchChoice") ) { Link Here
153
    $template->param( branchloop => $branchloop );
153
    $template->param( branchloop => $branchloop );
154
}
154
}
155
155
156
my $mandatoryfields = '';
157
{
158
    my $fldsreqsp = C4::Context->preference("OPACSuggestionMandatoryFields");
159
    last unless ($op eq 'add' && $fldsreqsp);
160
    my $supported_rf = {
161
        map { ($_, 1); } qw(
162
            author copyrightdate isbn publishercode collectiontitle
163
            place itemtype patronreason note
164
        )
165
    };
166
    my %fh = map {
167
        ($_ && $supported_rf->{$_})? ('"'.$_.'"', 1): ();
168
    } (split(/\s*\|\s*/, $fldsreqsp));
169
    $mandatoryfields = join(',', (sort keys %fh));
170
}
171
156
$template->param(
172
$template->param(
157
	%$suggestion,
173
	%$suggestion,
158
	itemtypeloop=> $supportlist,
174
	itemtypeloop=> $supportlist,
Lines 161-166 $template->param( Link Here
161
    showall    => $allsuggestions,
177
    showall    => $allsuggestions,
162
    "op_$op"         => 1,
178
    "op_$op"         => 1,
163
    suggestionsview => 1,
179
    suggestionsview => 1,
180
    mandatoryfields => $mandatoryfields,
164
);
181
);
165
182
166
output_html_with_http_headers $input, $cookie, $template->output;
183
output_html_with_http_headers $input, $cookie, $template->output;
167
- 

Return to bug 10848