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

(-)a/C4/Serials.pm (-12 / +5 lines)
Lines 2027-2038 sub delroutingmember { Link Here
2027
2027
2028
=head2 getroutinglist
2028
=head2 getroutinglist
2029
2029
2030
($count,@routinglist) = getroutinglist($subscriptionid)
2030
@routinglist = getroutinglist($subscriptionid)
2031
2031
2032
this gets the info from the subscriptionroutinglist for $subscriptionid
2032
this gets the info from the subscriptionroutinglist for $subscriptionid
2033
2033
2034
return :
2034
return :
2035
a count of the number of members on routinglist
2036
the routinglist as an array. Each element of the array contains a hash_ref containing
2035
the routinglist as an array. Each element of the array contains a hash_ref containing
2037
routingid - a unique id, borrowernumber, ranking, and biblionumber of subscription
2036
routingid - a unique id, borrowernumber, ranking, and biblionumber of subscription
2038
2037
Lines 2042-2061 sub getroutinglist { Link Here
2042
    my ($subscriptionid) = @_;
2041
    my ($subscriptionid) = @_;
2043
    my $dbh              = C4::Context->dbh;
2042
    my $dbh              = C4::Context->dbh;
2044
    my $sth              = $dbh->prepare(
2043
    my $sth              = $dbh->prepare(
2045
        "SELECT routingid, borrowernumber, ranking, biblionumber 
2044
        'SELECT routingid, borrowernumber, ranking, biblionumber
2046
            FROM subscription 
2045
            FROM subscription 
2047
            JOIN subscriptionroutinglist ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid
2046
            JOIN subscriptionroutinglist ON subscription.subscriptionid = subscriptionroutinglist.subscriptionid
2048
            WHERE subscription.subscriptionid = ? ORDER BY ranking ASC
2047
            WHERE subscription.subscriptionid = ? ORDER BY ranking ASC'
2049
                              "
2050
    );
2048
    );
2051
    $sth->execute($subscriptionid);
2049
    $sth->execute($subscriptionid);
2052
    my @routinglist;
2050
    my $routinglist = $sth->fetchall_arrayref({});
2053
    my $count = 0;
2051
    return @{$routinglist};
2054
    while ( my $line = $sth->fetchrow_hashref ) {
2055
        $count++;
2056
        push( @routinglist, $line );
2057
    }
2058
    return ( $count, @routinglist );
2059
}
2052
}
2060
2053
2061
=head2 countissuesfrom
2054
=head2 countissuesfrom
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt (-7 / +21 lines)
Lines 47-62 function search_member(subscriptionid){ Link Here
47
[% END %]
47
[% END %]
48
</select> [% issue %]</li>
48
</select> [% issue %]</li>
49
49
50
[% IF ( memberloop ) %]
50
[% IF memberloop %]
51
<li><span class="label">Recipients:</span><table style="clear:none;margin:0;">
51
<li><span class="label">Recipients:</span><table style="clear:none;margin:0;">
52
        <tr><th>Name</th>
52
        <tr><th>Name</th>
53
            <th>Rank</th>
53
            <th>Rank</th>
54
            <th>Delete</th></tr>
54
            <th>Delete</th>
55
[% FOREACH memberloo IN memberloop %]
55
        </tr>
56
        <tr><td>[% memberloo.name %]</td>
56
        [% USE m_loop = iterator(memberloop) %]
57
            <td>[% memberloo.routingbox %]</td>
57
        [% FOREACH member IN m_loop %]
58
            <td><a href="/cgi-bin/koha/serials/routing.pl?routingid=[% memberloo.routingid %]&amp;subscriptionid=[% subscriptionid %]&amp;op=delete">Delete</a></td></tr>
58
        <tr><td>[% member.name %]</td>
59
[% END %]
59
            <td>
60
                <select name="itemrank" onchange="reorder_item([%- subscriptionid -%], [%- member.routingid -%], this.option[this.selectedIndex].value)">
61
                [% rankings = [1 .. m_loop.size] %]
62
                [% FOREACH r IN rankings %]
63
                    [% IF r == member.ranking %]
64
                      <option selected="selected" value="[% r %]">[% r %]</option>
65
                    [% ELSE %]
66
                      <option value="[% r %]">[% r %]</option>
67
                    [% END %]
68
                [% END %]
69
                </select>
70
            </td>
71
            <td><a href="/cgi-bin/koha/serials/routing.pl?routingid=[% member.routingid %]&amp;subscriptionid=[% subscriptionid %]&amp;op=delete">Delete</a></td>
72
        </tr>
73
        [% END %]
60
        </table><p style="margin-left:10em;"><a onclick="search_member([% subscriptionid %]); return false"
74
        </table><p style="margin-left:10em;"><a onclick="search_member([% subscriptionid %]); return false"
61
href="/cgi-bin/koha/serials/member-search.pl?subscriptionid=[% subscriptionid %]" class="button">Add recipients</a> &nbsp; <a
75
href="/cgi-bin/koha/serials/member-search.pl?subscriptionid=[% subscriptionid %]" class="button">Add recipients</a> &nbsp; <a
62
href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid %]&amp;op=delete" class="button">Delete All</a></p></li>
76
href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid %]&amp;op=delete" class="button">Delete All</a></p></li>
(-)a/serials/routing-preview.pl (-22 / +17 lines)
Lines 56-62 if($edit){ Link Here
56
    print $query->redirect("routing.pl?subscriptionid=$subscriptionid");
56
    print $query->redirect("routing.pl?subscriptionid=$subscriptionid");
57
}
57
}
58
58
59
my ($routing, @routinglist) = getroutinglist($subscriptionid);
59
my @routinglist = getroutinglist($subscriptionid);
60
my $subs = GetSubscription($subscriptionid);
60
my $subs = GetSubscription($subscriptionid);
61
my ($tmp ,@serials) = GetSerials($subscriptionid);
61
my ($tmp ,@serials) = GetSerials($subscriptionid);
62
my ($template, $loggedinuser, $cookie);
62
my ($template, $loggedinuser, $cookie);
Lines 81-98 if($ok){ Link Here
81
		my $const = 'o';
81
		my $const = 'o';
82
		my $notes;
82
		my $notes;
83
		my $title = $subs->{'bibliotitle'};
83
		my $title = $subs->{'bibliotitle'};
84
		for(my $i=0;$i<$routing;$i++){
84
        for my $routing ( @routinglist ) {
85
			my $sth = $dbh->prepare("SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ?");
85
            my $sth = $dbh->prepare('SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? LIMIT 1');
86
				$sth->execute($biblio,$routinglist[$i]->{'borrowernumber'});
86
            $sth->execute($biblio,$routing->{borrowernumber});
87
				my $data = $sth->fetchrow_hashref;
87
            my $reserve = $sth->fetchrow_hashref;
88
88
89
		#       warn "$routinglist[$i]->{'borrowernumber'} is the same as $data->{'borrowernumber'}";
89
            if($routing->{borrowernumber} == $reserve->{borrowernumber}){
90
			if($routinglist[$i]->{'borrowernumber'} == $data->{'borrowernumber'}){
90
                ModReserve($routing->{ranking},$biblio,$routing->{borrowernumber},$branch);
91
				ModReserve($routinglist[$i]->{'ranking'},$biblio,$routinglist[$i]->{'borrowernumber'},$branch);
91
            } else {
92
				} else {
92
                AddReserve($branch,$routing->{borrowernumber},$biblio,$const,\@bibitems,$routing->{ranking}, undef, undef, $notes,$title);
93
				AddReserve($branch,$routinglist[$i]->{'borrowernumber'},$biblio,$const,\@bibitems,$routinglist[$i]->{'ranking'},'',$notes,$title);
93
        }
94
			}
94
    }
95
    	}
96
	}
95
	}
97
96
98
    ($template, $loggedinuser, $cookie)
97
    ($template, $loggedinuser, $cookie)
Lines 115-129 if($ok){ Link Here
115
				});
114
				});
116
}
115
}
117
116
118
my @results;
117
my $memberloop = [];
119
my $data;
118
for my $routing (@routinglist) {
120
for(my $i=0;$i<$routing;$i++){
119
    my $member = GetMember( borrowernumber => $routing->{borrowernumber} );
121
    $data=GetMember('borrowernumber' => $routinglist[$i]->{'borrowernumber'});
120
    $member->{name}           = "$member->{firstname} $member->{surname}";
122
    $data->{'location'}=$data->{'branchcode'};
121
    push @{$memberloop}, $member;
123
    $data->{'name'}="$data->{'firstname'} $data->{'surname'}";
124
    $data->{'routingid'}=$routinglist[$i]->{'routingid'};
125
    $data->{'subscriptionid'}=$subscriptionid;
126
    push(@results, $data);
127
}
122
}
128
123
129
my $routingnotes = $serials[0]->{'routingnotes'};
124
my $routingnotes = $serials[0]->{'routingnotes'};
Lines 134-140 $template->param( Link Here
134
    issue => $issue,
129
    issue => $issue,
135
    issue_escaped => URI::Escape::uri_escape($issue),
130
    issue_escaped => URI::Escape::uri_escape($issue),
136
    subscriptionid => $subscriptionid,
131
    subscriptionid => $subscriptionid,
137
    memberloop => \@results,
132
    memberloop => $memberloop,
138
    routingnotes => $routingnotes,
133
    routingnotes => $routingnotes,
139
    hasRouting => check_routing($subscriptionid),
134
    hasRouting => check_routing($subscriptionid),
140
    );
135
    );
(-)a/serials/routing.pl (-44 / +20 lines)
Lines 60-72 if($op eq 'add'){ Link Here
60
    addroutingmember($borrowernumber,$subscriptionid);
60
    addroutingmember($borrowernumber,$subscriptionid);
61
}
61
}
62
if($op eq 'save'){
62
if($op eq 'save'){
63
    my $sth = $dbh->prepare("UPDATE serial SET routingnotes = ? WHERE subscriptionid = ?");
63
    my $sth = $dbh->prepare('UPDATE serial SET routingnotes = ? WHERE subscriptionid = ?');
64
    $sth->execute($notes,$subscriptionid);
64
    $sth->execute($notes,$subscriptionid);
65
    my $urldate = URI::Escape::uri_escape($date_selected);
65
    my $urldate = URI::Escape::uri_escape($date_selected);
66
    print $query->redirect("routing-preview.pl?subscriptionid=$subscriptionid&issue=$urldate");
66
    print $query->redirect("routing-preview.pl?subscriptionid=$subscriptionid&issue=$urldate");
67
}
67
}
68
68
69
my ($routing, @routinglist) = getroutinglist($subscriptionid);
69
my @routinglist = getroutinglist($subscriptionid);
70
my $subs = GetSubscription($subscriptionid);
70
my $subs = GetSubscription($subscriptionid);
71
my ($count,@serials) = GetSerials($subscriptionid);
71
my ($count,@serials) = GetSerials($subscriptionid);
72
my $serialdates = GetLatestSerials($subscriptionid,$count);
72
my $serialdates = GetLatestSerials($subscriptionid,$count);
Lines 86-150 foreach my $dateseq (@{$serialdates}) { Link Here
86
}
86
}
87
87
88
my ($template, $loggedinuser, $cookie)
88
my ($template, $loggedinuser, $cookie)
89
= get_template_and_user({template_name => "serials/routing.tmpl",
89
= get_template_and_user({template_name => 'serials/routing.tmpl',
90
				query => $query,
90
				query => $query,
91
				type => "intranet",
91
				type => 'intranet',
92
				authnotrequired => 0,
92
				authnotrequired => 0,
93
				flagsrequired => {serials => 'routing'},
93
				flagsrequired => {serials => 'routing'},
94
				debug => 1,
94
				debug => 1,
95
				});
95
				});
96
96
97
my @results;
97
my $member_loop = [];
98
my $data;
98
for my $routing ( @routinglist ) {
99
for(my $i=0;$i<$routing;$i++){
99
    my $member=GetMember('borrowernumber' => $routing->{borrowernumber});
100
    $data=GetMember('borrowernumber' => $routinglist[$i]->{'borrowernumber'});
100
    $member->{location} = $member->{branchcode};
101
    $data->{'location'}=$data->{'branchcode'};
101
    if ($member->{firstname} ) {
102
    if ($data->{firstname} ) {
102
        $member->{name} = $member->{firstname} . q| |;
103
        $data->{name} = $data->{firstname} . q| |;
104
    }
103
    }
105
    else {
104
    else {
106
        $data->{name} = q{};
105
        $member->{name} = q{};
107
    }
106
    }
108
    if ($data->{surname} ) {
107
    if ($member->{surname} ) {
109
        $data->{name} .= $data->{surname};
108
        $member->{name} .= $member->{surname};
110
    }
109
    }
111
    $data->{'routingid'}=$routinglist[$i]->{'routingid'};
110
    $member->{routingid}=$routing->{routingid} || q{};
112
    $data->{'subscriptionid'}=$subscriptionid;
111
    $member->{ranking} = $routing->{ranking} || q{};
113
    if (! $routinglist[$i]->{routingid} ) {
114
        $routinglist[$i]->{routingid} = q||;
115
    }
116
    my $rankingbox = '<select name="itemrank" onchange="reorder_item('
117
    . $subscriptionid . ',' .$routinglist[$i]->{'routingid'} . ',this.options[this.selectedIndex].value)">';
118
    for(my $j=1; $j <= $routing; $j++) {
119
	$rankingbox .= "<option ";
120
	if($routinglist[$i]->{ranking} && $routinglist[$i]->{ranking} == $j){
121
	    $rankingbox .= " selected=\"selected\"";
122
	}
123
	$rankingbox .= " value=\"$j\">$j</option>";
124
    }
125
    $rankingbox .= "</select>";
126
    $data->{'routingbox'} = $rankingbox;
127
128
    push(@results, $data);
129
}
130
112
131
# for adding routing list
113
    push(@{$member_loop}, $member);
132
my $new;
133
if ($op eq 'new') {
134
    $new = 1;
135
} else {
136
# for modify routing list default
137
    $new = 0;
138
}
114
}
139
115
140
$template->param(
116
$template->param(
141
    title => $subs->{'bibliotitle'},
117
    title => $subs->{bibliotitle},
142
    subscriptionid => $subscriptionid,
118
    subscriptionid => $subscriptionid,
143
    memberloop => \@results,
119
    memberloop => $member_loop,
144
    op => $new,
120
    op => $op eq 'new',
145
    dates => $dates,
121
    dates => $dates,
146
    routingnotes => $serials[0]->{'routingnotes'},
122
    routingnotes => $serials[0]->{'routingnotes'},
147
    hasRouting => check_routing($subscriptionid),
123
    hasRouting => check_routing($subscriptionid),
148
    );
124
    );
149
125
150
        output_html_with_http_headers $query, $cookie, $template->output;
126
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/serials/subscription-detail.pl (-2 / +1 lines)
Lines 46-52 if ($op && $op eq 'del') { Link Here
46
	print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=serials-home.pl\"></html>";
46
	print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=serials-home.pl\"></html>";
47
	exit;
47
	exit;
48
}
48
}
49
my ($routing, @routinglist) = getroutinglist($subscriptionid);
49
50
my ($totalissues,@serialslist) = GetSerials($subscriptionid);
50
my ($totalissues,@serialslist) = GetSerials($subscriptionid);
51
$totalissues-- if $totalissues; # the -1 is to have 0 if this is a new subscription (only 1 issue)
51
$totalissues-- if $totalissues; # the -1 is to have 0 if this is a new subscription (only 1 issue)
52
# the subscription must be deletable if there is NO issues for a reason or another (should not happend, but...)
52
# the subscription must be deletable if there is NO issues for a reason or another (should not happend, but...)
53
- 

Return to bug 6790