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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt (-14 / +36 lines)
Lines 1-5 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; Tools &rsaquo; Notices[% IF ( add_form ) %][% IF ( modify ) %] &rsaquo; Modify notice[% ELSE %] &rsaquo; Add notice[% END %][% END %][% IF ( add_validate ) %] &rsaquo; Notice added[% END %][% IF ( delete_confirm ) %] &rsaquo; Confirm deletion[% END %]</title>
2
<title>Koha &rsaquo; Tools &rsaquo; Notices[% IF ( add_form or copy_form ) %][% IF ( modify ) %] &rsaquo; Modify notice[% ELSE %] &rsaquo; Add notice[% END %][% END %][% IF ( add_validate or copy_validate) %] &rsaquo; Notice added[% END %][% IF ( delete_confirm ) %] &rsaquo; Confirm deletion[% END %]</title>
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
4
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
5
[% INCLUDE 'datatables.inc' %]
5
[% INCLUDE 'datatables.inc' %]
Lines 24-30 $(document).ready(function() { Link Here
24
      });
24
      });
25
    [% END %]
25
    [% END %]
26
}); 
26
}); 
27
[% IF ( add_form ) %]
27
[% IF add_form or copy_form %]
28
	
28
	
29
    function cancel(f) {
29
    function cancel(f) {
30
        $('#op').val("");
30
        $('#op').val("");
Lines 112-125 $(document).ready(function() { Link Here
112
[% INCLUDE 'header.inc' %]
112
[% INCLUDE 'header.inc' %]
113
[% INCLUDE 'letters-search.inc' %]
113
[% INCLUDE 'letters-search.inc' %]
114
114
115
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% IF ( add_form ) %][% IF ( modify ) %]<a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Modify notice[% ELSE %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Add notice[% END %][% ELSE %][% IF ( add_validate ) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Notice added[% ELSE %][% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Confirm deletion[% ELSE %]Notices &amp; Slips[% END %][% END %][% END %]</div>
115
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; [% IF ( add_form or copy_form) %][% IF ( modify ) %]<a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Modify notice[% ELSE %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Add notice[% END %][% ELSE %][% IF ( add_validate or copy_validate) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Notice added[% ELSE %][% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/tools/letter.pl">Notices &amp; Slips</a> &rsaquo; Confirm deletion[% ELSE %]Notices &amp; Slips[% END %][% END %][% END %]</div>
116
116
117
[% IF ( add_form ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
117
[% IF add_form or copy_form %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
118
   
118
   
119
   <div id="bd">
119
   <div id="bd">
120
	<div id="yui-main">
120
	<div id="yui-main">
121
	<div class="yui-b">
121
	<div class="yui-b">
122
122
123
    [% IF already_exists %]
124
        <div class="dialog alert">This code already exists. Please change it.</div>
125
    [% END %]
126
123
[% IF ( no_op_set ) %]
127
[% IF ( no_op_set ) %]
124
    <h1>Notices and Slips</h1>
128
    <h1>Notices and Slips</h1>
125
    <form method="get" action="/cgi-bin/koha/tools/letter.pl" id="selectlibrary">
129
    <form method="get" action="/cgi-bin/koha/tools/letter.pl" id="selectlibrary">
Lines 180-186 $(document).ready(function() { Link Here
180
				<td style="white-space: nowrap">
184
				<td style="white-space: nowrap">
181
        [% IF !independant_branch || !lette.branchcode %]
185
        [% IF !independant_branch || !lette.branchcode %]
182
                    <form method="post" action="/cgi-bin/koha/tools/letter.pl">
186
                    <form method="post" action="/cgi-bin/koha/tools/letter.pl">
183
                        <input type="hidden" name="op" value="copy" />
187
                        <input type="hidden" name="op" value="copy_form" />
184
				        <input type="hidden" name="oldbranchcode" value="[% lette.branchcode %]" />
188
				        <input type="hidden" name="oldbranchcode" value="[% lette.branchcode %]" />
185
                        <input type="hidden" name="module" value="[% lette.module %]" />
189
                        <input type="hidden" name="module" value="[% lette.module %]" />
186
                        <input type="hidden" name="code" value="[% lette.code %]" />
190
                        <input type="hidden" name="code" value="[% lette.code %]" />
Lines 219-228 $(document).ready(function() { Link Here
219
[% END %]
223
[% END %]
220
224
221
	
225
	
222
[% IF ( add_form ) %]
226
[% IF add_form or copy_form %]
223
<h1>[% IF ( modify ) %]Modify notice[% ELSE %]Add notice[% END %]</h1>
227
<h1>[% IF ( modify ) %]Modify notice[% ELSE %]Add notice[% END %]</h1>
224
		<form action="?" name="Aform" method="post">
228
		<form action="?" name="Aform" method="post">
225
		<input type="hidden" name="op" id="op" value="add_validate" />
229
        [% IF add_form %]
230
          <input type="hidden" name="op" id="op" value="add_validate" />
231
        [% ELSE %]
232
          <input type="hidden" name="op" id="op" value="copy_validate" />
233
        [% END %]
234
226
		<input type="hidden" name="checked" value="0" />
235
		<input type="hidden" name="checked" value="0" />
227
		[% IF ( modify ) %]
236
		[% IF ( modify ) %]
228
		<input type="hidden" name="add" value="0" />
237
		<input type="hidden" name="add" value="0" />
Lines 230-236 $(document).ready(function() { Link Here
230
		<input type="hidden" name="add" value="1" />
239
		<input type="hidden" name="add" value="1" />
231
		[% END %]
240
		[% END %]
232
		<fieldset class="rows">
241
		<fieldset class="rows">
233
				<input type="hidden" name="oldbranchcode" value="[% branchcode %]" />
242
            <input type="hidden" name="oldbranchcode" value="[% oldbranchcode %]" />
234
            [% IF independant_branch %]
243
            [% IF independant_branch %]
235
                <input type="hidden" name="branchcode" value="[% independant_branch %]" />
244
                <input type="hidden" name="branchcode" value="[% independant_branch %]" />
236
            [% ELSE %]
245
            [% ELSE %]
Lines 248-254 $(document).ready(function() { Link Here
248
			<li>
257
			<li>
249
				<label for="module">Koha module:</label>
258
				<label for="module">Koha module:</label>
250
				<input type="hidden" name="oldmodule" value="[% module %]" />
259
				<input type="hidden" name="oldmodule" value="[% module %]" />
251
		[% IF ( modify ) %]<select name="module" id="module">[% END %] [% IF ( adding ) %] <select name="module" id="module" onchange="javascript:window.location.href = unescape(window.location.pathname)+'?op=add_form&amp;module='+this.value+'&amp;content='+window.document.forms['Aform'].elements['content'].value;">[% END %]
260
                [% IF adding  %]
261
                  <select name="module" id="module" onchange="javascript:window.location.href = unescape(window.location.pathname)+'?op=add_form&amp;module='+this.value+'&amp;content='+window.document.forms['Aform'].elements['content'].value;">
262
                [% ELSE %]
263
                  <select name="module" id="module">
264
                [% END %]
252
                                    [% IF ( catalogue ) %]
265
                                    [% IF ( catalogue ) %]
253
                                    <option value="catalogue" selected="selected">Catalog</option>
266
                                    <option value="catalogue" selected="selected">Catalog</option>
254
                                    [% ELSE %]
267
                                    [% ELSE %]
Lines 291-299 $(document).ready(function() { Link Here
291
                                    [% END %]
304
                                    [% END %]
292
				</select>
305
				</select>
293
			</li>
306
			</li>
294
			<li>
307
            <li>
295
				<span class="label">Code:</span>[% IF ( adding ) %]<input type="text" id="code" name="code" size="20" maxlength="20" />[% ELSE %]<input type="hidden" id="code" name="code" value="[% code %]" />[% code %][% END %]
308
              <span class="label">Code:</span>
296
			</li>
309
              [% IF adding or copying %]
310
                <input type="text" id="code" name="code" size="20" maxlength="20" value="[% code %]"/>
311
                [% IF copying %]
312
                  You must change this code to reflect the copy.
313
                [% END %]
314
              [% ELSE %]
315
                <input type="hidden" id="code" name="code" value="[% code %]" />[% code %]
316
              [% END %]
317
              <input type="hidden" id="code" name="oldcode" value="[% oldcode %]" />
318
            </li>
297
		<li>
319
		<li>
298
			<label for="name">Name:</label><input type="text" id="name" name="name" size="60" value="[% name %]" />
320
			<label for="name">Name:</label><input type="text" id="name" name="name" size="60" value="[% name %]" />
299
		</li>
321
		</li>
Lines 328-334 $(document).ready(function() { Link Here
328
		</form>
350
		</form>
329
[% END %]
351
[% END %]
330
	
352
	
331
[% IF ( add_validate ) %]
353
[% IF ( add_validate or copy_validate) %]
332
	Data recorded
354
	Data recorded
333
	<form action="[% action %]" method="post">
355
	<form action="[% action %]" method="post">
334
	<input type="submit" value="OK" />
356
	<input type="submit" value="OK" />
Lines 377-383 $(document).ready(function() { Link Here
377
399
378
</div>
400
</div>
379
</div>
401
</div>
380
[% UNLESS ( add_form ) %]
402
[% UNLESS add_form or copy_form %]
381
    <div class="yui-b noprint">
403
    <div class="yui-b noprint">
382
        [% INCLUDE 'tools-menu.inc' %]
404
        [% INCLUDE 'tools-menu.inc' %]
383
    </div>
405
    </div>
(-)a/tools/letter.pl (-32 / +41 lines)
Lines 76-82 sub letter_exists { Link Here
76
    my $letter = $dbh->selectrow_hashref("SELECT * $sql", undef, @$args);
76
    my $letter = $dbh->selectrow_hashref("SELECT * $sql", undef, @$args);
77
    return $letter;
77
    return $letter;
78
}
78
}
79
79
sub lettercode_exists {
80
    my ( $letter_code ) = @_;
81
    my $dbh = C4::Context->dbh;
82
    my ( $exist ) = $dbh->selectrow_array("SELECT count(*) FROM letter where code=?", undef, $letter_code);
83
    return $exist;
84
}
80
# $protected_letters = protected_letters()
85
# $protected_letters = protected_letters()
81
# - return a hashref of letter_codes representing letters that should never be deleted
86
# - return a hashref of letter_codes representing letters that should never be deleted
82
sub protected_letters {
87
sub protected_letters {
Lines 119-135 $template->param( Link Here
119
	action => $script_name
124
	action => $script_name
120
);
125
);
121
126
122
if ($op eq 'copy') {
127
if ( $op eq 'add_validate' or $op eq 'copy_validate' ) {
123
    add_copy();
128
    my $added = add_validate();
124
    $op = 'add_form';
129
    unless ( $added ) {
130
        if ( $op eq 'add_validate' ) {
131
            $op = 'add_form';
132
        } else {
133
            $op = 'copy_form';
134
            $code = $input->param('oldcode');
135
        }
136
        $template->param( already_exists => 1 );
137
    }
138
    else {
139
        $op = q{}; # next operation is to return to default screen
140
    }
125
}
141
}
126
142
if ($op eq 'copy_form') {
127
if ($op eq 'add_form') {
143
    my $oldbranchcode = $input->param('oldbranchcode') || q||;
128
    add_form($branchcode, $module, $code);
144
    my $branchcode = $input->param('branchcode') || q||;
145
    my $oldcode = $input->param('oldcode') || $input->param('code');
146
    add_form($oldbranchcode, $module, $code);
147
    $template->param(
148
        oldbranchcode => $oldbranchcode,
149
        branchcode => $branchcode,
150
        branchloop => _branchloop($branchcode),
151
        oldcode => $oldcode,
152
        copying => 1,
153
        modify => 0,
154
    );
129
}
155
}
130
elsif ( $op eq 'add_validate' ) {
156
elsif ( $op eq 'add_form' ) {
131
    add_validate();
157
    add_form($branchcode, $module, $code);
132
    $op = q{}; # next operation is to return to default screen
133
}
158
}
134
elsif ( $op eq 'delete_confirm' ) {
159
elsif ( $op eq 'delete_confirm' ) {
135
    delete_confirm($branchcode, $module, $code);
160
    delete_confirm($branchcode, $module, $code);
Lines 227-233 sub add_form { Link Here
227
252
228
sub add_validate {
253
sub add_validate {
229
    my $dbh        = C4::Context->dbh;
254
    my $dbh        = C4::Context->dbh;
230
    my $oldbranchcode = $input->param('oldbranchcode');
231
    my $branchcode    = $input->param('branchcode') || '';
255
    my $branchcode    = $input->param('branchcode') || '';
232
    my $module        = $input->param('module');
256
    my $module        = $input->param('module');
233
    my $oldmodule     = $input->param('oldmodule');
257
    my $oldmodule     = $input->param('oldmodule');
Lines 236-247 sub add_validate { Link Here
236
    my $is_html       = $input->param('is_html');
260
    my $is_html       = $input->param('is_html');
237
    my $title         = $input->param('title');
261
    my $title         = $input->param('title');
238
    my $content       = $input->param('content');
262
    my $content       = $input->param('content');
239
    if (letter_exists($oldbranchcode,$oldmodule, $code)) {
263
    if ( lettercode_exists( $code ) ) {
264
        return 0;
265
    }
266
    elsif (letter_exists($branchcode,$oldmodule, $code)) {
240
        $dbh->do(
267
        $dbh->do(
241
            q{UPDATE letter SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ? WHERE branchcode = ? AND module = ? AND code = ?},
268
            q{UPDATE letter SET branchcode = ?, module = ?, name = ?, is_html = ?, title = ?, content = ? WHERE branchcode = ? AND module = ? AND code = ?},
242
            undef,
269
            undef,
243
            $branchcode, $module, $name, $is_html || 0, $title, $content,
270
            $branchcode, $module, $name, $is_html || 0, $title, $content,
244
            $oldbranchcode, $oldmodule, $code
271
            $branchcode, $oldmodule, $code
245
        );
272
        );
246
    } else {
273
    } else {
247
        $dbh->do(
274
        $dbh->do(
Lines 252-275 sub add_validate { Link Here
252
    }
279
    }
253
    # set up default display
280
    # set up default display
254
    default_display($branchcode);
281
    default_display($branchcode);
255
}
282
    return 1;
256
257
sub add_copy {
258
    my $dbh        = C4::Context->dbh;
259
    my $oldbranchcode = $input->param('oldbranchcode');
260
    my $branchcode    = $input->param('branchcode');
261
    my $module        = $input->param('module');
262
    my $code          = $input->param('code');
263
264
    return if letter_exists($branchcode,$module, $code);
265
266
    my $old_letter = letter_exists($oldbranchcode,$module, $code);
267
268
    $dbh->do(
269
        q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content) VALUES (?,?,?,?,?,?,?)},
270
        undef,
271
        $branchcode, $module, $code, $old_letter->{name}, $old_letter->{is_html}, $old_letter->{title}, $old_letter->{content}
272
    );
273
}
283
}
274
284
275
sub delete_confirm {
285
sub delete_confirm {
276
- 

Return to bug 11742