use Carp;
+use Koha::Borrowers;
+
use base qw(Koha::Object);
=head1 NAME
=cut
+=head3 patrons_using
+
+my $count = $provider->patrons_using()
+
+Gives the number of patrons using this provider
+
+=cut
+
+sub patrons_using {
+ my ( $self ) = @_;
+
+ return Koha::Borrowers->search( { sms_provider_id => $self->id } )->count();
+}
+
=head3 type
=cut
<tr>
<th>Name</th>
<th>Domain</th>
+ <th title="Patrons using this provider">Patrons</th>
<th> </th>
<th> </th>
</tr>
<tr>
<td id="name_[% p.id %]">[% p.name %]</td>
<td id="domain_[% p.id %]">[% p.domain %]</td>
- <td><a href="#" id="edit_[% p.id %]" class="edit" onclick="edit_provider( [% p.id %] );">Edit</td>
- <td><a href="#" id="delete_[% p.id %]" class="delete" onclick="delete_provider( [% p.id %] );">Delete</td>
+ <td id="patrons_using_[% p.id %]">[% p.patrons_using %]</td>
+ <td>
+ <a class="btn" href="#" id="edit_[% p.id %]" class="edit" onclick="edit_provider( [% p.id %] );">
+ <i class="fa fa-pencil"></i> Edit
+ </a>
+ </td>
+ <td>
+ [% IF p.patrons_using %]
+ <a class="btn btn-danger" href="#" id="delete_[% p.id %]" class="delete" onclick="delete_provider( [% p.id %] );">
+ <span style="color:white"><i class="fa fa-trash"></i> Delete</span>
+ </a>
+ [% ELSE %]
+ <a class="btn" href="#" id="delete_[% p.id %]" class="delete" onclick="delete_provider( [% p.id %] );">
+ <i class="fa fa-trash"></i> Delete
+ </a>
+ [% END %]
+ </td>
</tr>
[% END %]
</tbody>
<tr>
<td><input type="text" id="name" name="name" /></td>
<td><input type="text" id="domain" name="domain" size="40"/></td>
+ <td colspan="2">
+ <button class="btn" id="submit_save" type="submit">
+ <i class="fa fa-plus"></i> Add new
+ </button>
+ <button class="btn" id="submit_update" type="submit">
+ <i class="fa fa-plus-circle"></i> Update
+ </button>
+ </td>
<td>
- <input id="submit_save" type="submit" value="Add new">
- <input id="submit_update" type="submit" value="Update">
+ <a class="btn" id="cancel" href="#" onclick="cancel_edit()">
+ <i class="fa fa-ban"></i> Cancel
+ </a>
</td>
- <td><a id="cancel" href="#" onclick="cancel_edit()">Cancel</a></td>
</tr>
</form>
</tfoot>