my $key = $c->categorycode . "-" . $i->itemtype . "-" . $notification;
$key =~ s/\*/_/g;
my @classes;
+ my $text = " ";
if ($disabled{$key}) {
push @classes, 'disabled';
+ $text = "Disabled for $where->{branchcode}";
}
if ($default{$key}) {
push @classes, 'default';
+ $text = "Disabled for all";
}
- push @{$row->{items}}, { class => join(' ', @classes), id => $key };
+ push @{$row->{items}}, {
+ class => join(' ', @classes),
+ id => $key,
+ text => $text,
+ };
}
}
return \@grid;
use CGI;
use File::Basename;
use Encode;
-use URI::Escape 'uri_escape_utf8';
use JSON;
#use Data::Dump 'pp';
my $br = GetBranches;
my $branch = $input->param('branch') || '*';
- my @branches = map { utf8($_, 'branchname') } (
+ my @branches = (
{
branchcode => '*',
branchname => 'Default',
}
my $branch_name = exists($br->{$branch}) && $br->{$branch}->{branchname};
- my @categories = map { utf8($_, 'description') } (
+ my @categories = (
C4::Category->all
);
- my @item_types = map { utf8($_, 'description'); br($_, 'description') } (
+ my @item_types = map { br($_, 'description') } (
C4::ItemType->all
);
my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
my $response = { success => 1 };
my @reasons = $notifications->is_disabled_for($settings);
if (@reasons == 0) {
- $response->{class} = '';
+ $response->{classes} = '';
} else {
my $default_exists = grep { $_->{branchcode} eq '*' } @reasons;
my $non_default_also = grep { $_->{branchcode} ne '*' } @reasons;
my @classes;
push @classes, 'default' if $default_exists;
push @classes, 'disabled' if $non_default_also;
- $response->{class} = join(' ', @classes);
+ $response->{classes} = join(' ', @classes);
}
print $input->header;
print encode_json($response);
Parameters:
-=over 4
+=over 2
=item branch
Parameters:
-=over 4
+=over 2
=item id
-"$categorycode-$item_type-$notification"
+The id should be string that can be split on "-" which contains:
+"$categorycode-$item_type-$notification".
=item branch
text-align: right;
}
+table.grid tbody td {
+ font-size: xx-small;
+}
+
table.grid tbody td.info {
background: #fff;
}
var $branch = "<!-- TMPL_VAR NAME="branch" -->";
$(function(){
+ var blocked = _('Blocked!');
+ var saving = _('Saving...');
+ var disabledForAll = _('Disabled for all');
+ var disabledForCurrent = _('Disabled for') + ' ' + $branch;
+
$('#branch_selector input:submit').hide();
$('#branch').change(function(){
$('#branch_selector').submit();
var id = this.id;
var td = $(this);
if (td.hasClass('default') && $branch != '*') {
- td.html(_('Blocked'));
+ td.html(blocked);
+ window.setTimeout(
+ function(){ td.html(disabledForAll) },
+ 3000
+ );
} else {
- td.html(_('Saving...'));
+ td.html(saving);
$.ajax({
url : '/cgi-bin/koha/admin/item_circulation_alerts.pl',
type : 'POST',
dataType : 'json',
data : { action: 'toggle', id: id, branch: $branch },
success : function(response){
- td.html(' ');
- td.attr('class', response.class);
+ if ($branch == '*' && response.classes.match(/default/)) {
+ td.html(disabledForAll);
+ } else if (response.classes.match(/disabled/)) {
+ td.html(disabledForCurrent);
+ } else {
+ td.html(' ');
+ }
+ td.attr('class', response.classes);
}
});
}
<tr>
<th><!-- TMPL_VAR NAME="description" --></th>
<!-- TMPL_LOOP NAME="items" -->
- <td class="<!-- TMPL_VAR NAME="class" -->" id="<!-- TMPL_VAR NAME="id" -->"> </td>
+ <td class="<!-- TMPL_VAR NAME="class" -->" id="<!-- TMPL_VAR NAME="id" -->"><!-- TMPL_VAR NAME="text" --></td>
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_LOOP -->
<tr>
<th><!-- TMPL_VAR NAME="description" --></th>
<!-- TMPL_LOOP NAME="items" -->
- <td class="<!-- TMPL_VAR NAME="class" -->" id="<!-- TMPL_VAR NAME="id" -->"> </td>
+ <td class="<!-- TMPL_VAR NAME="class" -->" id="<!-- TMPL_VAR NAME="id" -->"><!-- TMPL_VAR NAME="text" --></td>
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_LOOP -->