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

(-)a/admin/cities.pl (-4 / +11 lines)
Lines 27-33 use C4::Output; Link Here
27
use Koha::Cities;
27
use Koha::Cities;
28
28
29
my $input       = new CGI;
29
my $input       = new CGI;
30
my $searchfield = $input->param('city_name') // q||;
30
my $city_name   = $input->param('city_name') // q||;
31
my $cityid      = $input->param('cityid');
31
my $cityid      = $input->param('cityid');
32
my $op          = $input->param('op') || 'list';
32
my $op          = $input->param('op') || 'list';
33
my @messages;
33
my @messages;
Lines 84-91 if ( $op eq 'add_form' ) { Link Here
84
            push @messages, { type => 'message', code => 'success_on_insert' };
84
            push @messages, { type => 'message', code => 'success_on_insert' };
85
        }
85
        }
86
    }
86
    }
87
    $searchfield = q||;
87
    $city_name = q||;
88
    $op          = 'list';
88
    $op        = 'list';
89
} elsif ( $op eq 'delete_confirm' ) {
89
} elsif ( $op eq 'delete_confirm' ) {
90
    my $city = Koha::Cities->find($cityid);
90
    my $city = Koha::Cities->find($cityid);
91
    $template->param( city => $city, );
91
    $template->param( city => $city, );
Lines 101-109 if ( $op eq 'add_form' ) { Link Here
101
    $op = 'list';
101
    $op = 'list';
102
}
102
}
103
103
104
if ( $op eq 'list' ) {
105
    my $filter = {};
106
    $filter->{city_name} = { -like => '%'.$city_name.'%' }
107
        if $city_name;
108
    $template->param( cities_count => Koha::Cities->search($filter)->count );
109
}
110
104
$template->param(
111
$template->param(
105
    cityid      => $cityid,
112
    cityid      => $cityid,
106
    searchfield => $searchfield,
113
    city_name_filter => $city_name,
107
    messages    => \@messages,
114
    messages    => \@messages,
108
    op          => $op,
115
    op          => $op,
109
);
116
);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt (-17 / +31 lines)
Lines 129-150 Link Here
129
    </div>
129
    </div>
130
130
131
    <h2>Cities</h2>
131
    <h2>Cities</h2>
132
    [% IF searchfield %]
132
    [% IF city_name_filter %]
133
        Searching: [% searchfield | html %]
133
        Searching: [% city_name_filter | html %]
134
    [% END %]
134
    [% END %]
135
135
136
    <table id="table_cities">
136
    [% IF cities_count > 0 %]
137
        <thead>
137
        <table id="table_cities">
138
            <tr>
138
            <thead>
139
                <th>City ID</th>
139
                <tr>
140
                <th>City</th>
140
                    <th>City ID</th>
141
                <th>State</th>
141
                    <th>City</th>
142
                <th>ZIP/Postal code</th>
142
                    <th>State</th>
143
                <th>Country</th>
143
                    <th>ZIP/Postal code</th>
144
                <th>Actions</th>
144
                    <th>Country</th>
145
            </tr>
145
                    <th data-class-name="actions">Actions</th>
146
        </thead>
146
                </tr>
147
    </table>
147
            </thead>
148
        </table>
149
    [% ELSE %]
150
        <div class="dialog message">
151
            There are no cities defined. <a href="/cgi-bin/koha/admin/cities.pl?op=add_form">Create a new city</a>.
152
        </div>
153
    [% END %]
148
[% END %]
154
[% END %]
149
155
150
            </main>
156
            </main>
Lines 162-173 Link Here
162
    [% INCLUDE 'datatables.inc' %]
168
    [% INCLUDE 'datatables.inc' %]
163
    <script>
169
    <script>
164
        $(document).ready(function() {
170
        $(document).ready(function() {
165
            var cities_table_url = '/api/v1/cities';
171
            var cities_table_url = '/api/v1/cities?';
172
        [% IF city_name_filter %]
173
            var city_name_filter = {
174
                'name': {
175
                    "like": '%[%- city_name_filter | html -%]%'
176
                }
177
            };
178
            cities_table_url += 'q='+ encodeURI(JSON.stringify(city_name_filter));
179
        [% END %]
166
            var cities_table = $("#table_cities").api({
180
            var cities_table = $("#table_cities").api({
167
                "ajax": {
181
                "ajax": {
168
                    "url": cities_table_url
182
                    "url": cities_table_url
169
                },
183
                },
170
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
184
                'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>',
185
                "order": [[ 1, "asc" ]],
171
                "columns": [
186
                "columns": [
172
                    {
187
                    {
173
                        "data": "city_id",
188
                        "data": "city_id",
Lines 197-203 Link Here
197
                    {
212
                    {
198
                        "data": function( row, type, val, meta ) {
213
                        "data": function( row, type, val, meta ) {
199
214
200
                            var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/cities.pl?op=add_form&amp;cityid='+ row.city_id +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>';
215
                            var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/cities.pl?op=add_form&amp;cityid='+ row.city_id +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n";
201
                            result += '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/cities.pl?op=delete_confirm&amp;cityid='+ row.city_id +'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Delete")+'</a>';
216
                            result += '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/cities.pl?op=delete_confirm&amp;cityid='+ row.city_id +'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Delete")+'</a>';
202
                            return result;
217
                            return result;
203
218
204
- 

Return to bug 25279