Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions installer/data.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
-- MariaDB dump 10.19 Distrib 10.5.19-MariaDB, for debian-linux-gnu (x86_64)
/*M!999999\- enable the sandbox mode */
-- MariaDB dump 10.19 Distrib 10.5.29-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: libki-mariadb Database: libki
-- ------------------------------------------------------
-- Server version 10.3.5-MariaDB-10.3.5+maria~jessie
-- Server version 12.1.2-MariaDB-ubu2404

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
Expand Down Expand Up @@ -167,8 +168,8 @@ INSERT INTO `settings` VALUES ('','DefaultGuestSessionTimeAllowance','45');
INSERT INTO `settings` VALUES ('','DefaultGuestTimeAllowance','45');
INSERT INTO `settings` VALUES ('','DefaultSessionTimeAllowance','45');
INSERT INTO `settings` VALUES ('','DefaultTimeAllowance','45');
INSERT INTO `settings` VALUES ('','DisplayReservationStatusWithin','60');
INSERT INTO `settings` VALUES ('','DisplayPublicReservationsPage','enabled');
INSERT INTO `settings` VALUES ('','DisplayReservationStatusWithin','60');
INSERT INTO `settings` VALUES ('','GuestBatchCount','40');
INSERT INTO `settings` VALUES ('','MinimumReservationMinutes','5');
INSERT INTO `settings` VALUES ('','PostCrashTimeout','5');
Expand All @@ -177,9 +178,8 @@ INSERT INTO `settings` VALUES ('','ReservationShowUsername','RSD');
INSERT INTO `settings` VALUES ('','ReservationTimeout','15');
INSERT INTO `settings` VALUES ('','ShowFirstLastNames','1');
INSERT INTO `settings` VALUES ('','ThirdPartyURL','');
INSERT INTO `settings` VALUES ('','TimeDisplayFormat','24');
INSERT INTO `settings` VALUES ('','UserCategories','');
INSERT INTO `settings` VALUES ('','Version','5.2.1');
INSERT INTO `settings` VALUES ('','Version','5.2.x');
/*!40000 ALTER TABLE `settings` ENABLE KEYS */;
UNLOCK TABLES;

Expand All @@ -192,6 +192,15 @@ LOCK TABLES `statistics` WRITE;
/*!40000 ALTER TABLE `statistics` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Dumping data for table `transactions`
--

LOCK TABLES `transactions` WRITE;
/*!40000 ALTER TABLE `transactions` DISABLE KEYS */;
/*!40000 ALTER TABLE `transactions` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Dumping data for table `user_roles`
--
Expand All @@ -218,4 +227,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2023-07-17 7:52:06
-- Dump completed on 2026-02-11 10:59:54
12 changes: 7 additions & 5 deletions installer/schema.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
-- MariaDB dump 10.19 Distrib 10.11.13-MariaDB, for debian-linux-gnu (x86_64)
/*M!999999\- enable the sandbox mode */
-- MariaDB dump 10.19 Distrib 10.5.29-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: libki
-- Host: libki-mariadb Database: libki
-- ------------------------------------------------------
-- Server version 11.8.5-MariaDB-ubu2404
-- Server version 12.1.2-MariaDB-ubu2404

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
Expand Down Expand Up @@ -374,7 +375,7 @@ CREATE TABLE `transactions` (
KEY `idx_instance_status` (`instance`,`status`),
KEY `idx_created_on` (`created_on`),
CONSTRAINT `user_transactions_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
Expand Down Expand Up @@ -418,6 +419,7 @@ CREATE TABLE `users` (
`lastname` varchar(191) DEFAULT '',
`category` varchar(191) DEFAULT '',
`creation_source` varchar(191) DEFAULT NULL,
`gratis_print_balance` int(11) NOT NULL DEFAULT 0 COMMENT 'Number of free prints remaining; represents pages or cents depending on system settings',
PRIMARY KEY (`id`),
UNIQUE KEY `unique_username` (`instance`,`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
Expand All @@ -432,4 +434,4 @@ CREATE TABLE `users` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2025-12-19 13:32:36
-- Dump completed on 2026-02-11 10:59:54
3 changes: 3 additions & 0 deletions installer/versions/5/2.x_gratis_print_balance.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE `users`
ADD COLUMN `gratis_print_balance` INT(11) NOT NULL DEFAULT 0
COMMENT 'Number of free prints remaining; represents pages or cents depending on system settings';
18 changes: 10 additions & 8 deletions lib/Libki/Controller/API/PrintStation/v1_0.pm
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,22 @@ sub print_jobs : Path('print_jobs') : Args(0) {

my $print_jobs = [];
while ( my $j = $jobs->next ) {
my $cost = Libki::Utils::Printing::calculate_job_cost( $c, { print_job => $j } );
my ( $cost, $gratis_discount ) = Libki::Utils::Printing::calculate_job_cost( $c, { print_job => $j } );

push(
@$print_jobs,
{
print_job_id => $j->id,
printer => $j->printer,
copies => $j->copies,
created_on => $c->format_dt( { dt => $j->created_on, include_time => 1 } ),
print_file_id => $j->print_file_id,
pages => $j->print_file->pages,
cost => $cost,
print_job_id => $j->id,
printer => $j->printer,
copies => $j->copies,
created_on => $c->format_dt( { dt => $j->created_on, include_time => 1 } ),
print_file_id => $j->print_file_id,
pages => $j->print_file->pages,
cost => $cost,
gratis_discount => $gratis_discount,
}
);

}

my $data = {
Expand Down
1 change: 1 addition & 0 deletions lib/Libki/Controller/Administration.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ sub index : Path : Args(0) {
PrinterConfiguration => $c->setting('PrinterConfiguration'),
ShowFirstLastNames => $c->setting('ShowFirstLastNames'),
UserCategories => $c->setting('UserCategories'),
GratisPrintingValue => $c->setting('GratisPrintingValue'),
locations => \@locations,
types => \@types,
);
Expand Down
7 changes: 4 additions & 3 deletions lib/Libki/Controller/Administration/API/DataTables.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sub users : Local Args(0) {
my $params = $c->req->params;

# We need to map the table columns to field names for ordering
my @columns = qw/me.username me.lastname me.firstname me.category allotments.minutes session.minutes me.status me.notes me.is_troublemaker client.name session.status me.creation_source/;
my @columns = qw/me.username me.lastname me.firstname me.category allotments.minutes session.minutes me.funds me.gratis_print_balance me.status me.notes me.is_troublemaker client.name session.status me.creation_source/;

my $search_term = $params->{"search[value]"};
my $filter;
Expand Down Expand Up @@ -127,8 +127,9 @@ sub users : Local Args(0) {
category => $u->category,
client_name => defined( $u->session ) ? $u->session->client->name : undef,
creation_source => $u->creation_source,
firstname => $u->firstname,
funds => $u->funds,
firstname => $u->firstname,
funds => $u->funds,
gratis_print_balance => $u->gratis_print_balance,
is_troublemaker => $u->is_troublemaker,
lastname => $u->lastname,
minutes => $u->session ? $u->session->minutes : undef,
Expand Down
55 changes: 29 additions & 26 deletions lib/Libki/Controller/Administration/API/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,18 @@ sub get : Local : Args(1) {

$c->stash(
{
id => $user->id,
username => $user->username,
firstname => $user->firstname,
lastname => $user->lastname,
category => $user->category,
minutes => $user->minutes($c),
status => $user->status,
notes => $user->notes,
funds => $user->funds,
is_troublemaker => $user->is_troublemaker,
troublemaker_until => defined( $user->troublemaker_until )
id => $user->id,
username => $user->username,
firstname => $user->firstname,
lastname => $user->lastname,
category => $user->category,
minutes => $user->minutes($c),
status => $user->status,
notes => $user->notes,
funds => $user->funds,
gratis_print_balance => $user->gratis_print_balance,
is_troublemaker => $user->is_troublemaker,
troublemaker_until => defined( $user->troublemaker_until )
? $user->troublemaker_until->strftime('%Y-%m-%d 23:59')
: undef,
roles => \@roles,
Expand Down Expand Up @@ -220,15 +221,16 @@ sub update : Local : Args(0) {

my $success = 0;

my $id = $c->request->params->{'id'};
my $firstname = $c->request->params->{firstname};
my $lastname = $c->request->params->{lastname};
my $category = $c->request->params->{category};
my $minutes = $c->request->params->{'minutes'};
my $funds = $c->request->params->{'funds'};
my $notes = $c->request->params->{'notes'};
my $status = $c->request->params->{'status'};
my @roles = $c->request->params->{'roles'} || [];
my $id = $c->request->params->{'id'};
my $firstname = $c->request->params->{firstname};
my $lastname = $c->request->params->{lastname};
my $category = $c->request->params->{category};
my $minutes = $c->request->params->{'minutes'};
my $funds = $c->request->params->{'funds'};
my $notes = $c->request->params->{'notes'};
my $gratis_print_balance = $c->request->params->{'gratis_print_balance'} || 0;
my $status = $c->request->params->{'status'};
my @roles = $c->request->params->{'roles'} || [];

# For some reason the list of checkboxes are created
# as a list within a list if multiple are checked
Expand All @@ -247,12 +249,13 @@ sub update : Local : Args(0) {
$success = 1 if $user->update(
{

firstname => $firstname,
lastname => $lastname,
category => $category,
notes => $notes,
status => $status,
updated_on => $now,
firstname => $firstname,
lastname => $lastname,
category => $category,
gratis_print_balance => $gratis_print_balance,
notes => $notes,
status => $status,
updated_on => $now,
}
);

Expand Down
6 changes: 4 additions & 2 deletions lib/Libki/Controller/Public/API/DataTables.pm
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@ sub prints : Local Args(0) {
foreach my $print_job (@prints) {
my $print_file = $print_job->print_file;

my $total_cost = Libki::Utils::Printing::calculate_job_cost(
my ($total_cost, $gratis_discount) = Libki::Utils::Printing::calculate_job_cost(
$c,
{
print_job => $print_job,
print_file => $print_file,
printer => $printers->{printers}->{ $print_job->printer },
user => $user,
}
);

Expand All @@ -130,7 +131,7 @@ sub prints : Local Args(0) {
}
keys %{$printers->{printers}} ) {
my $printer = $printers->{printers}->{ $key };
my $total_cost = Libki::Utils::Printing::calculate_job_cost(
my ($total_cost, $gratis_discount) = Libki::Utils::Printing::calculate_job_cost(
$c,
{
print_job => $print_job,
Expand All @@ -143,6 +144,7 @@ sub prints : Local Args(0) {
selected => $key eq $print_job->printer ? 1 : 0,
name => $printer->{public_printer_name},
cost => $total_cost,
gratis_discount => $gratis_discount,
};

push( @printer_costs, $data );
Expand Down
3 changes: 2 additions & 1 deletion lib/Libki/Controller/Public/API/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ sub funds : Local Args(0) {
delete $c->stash->{$_} for keys %{$c->stash};
$c->stash(
{
funds => $user->funds
funds => $user->funds,
gratis_print_balance => $user->gratis_print_balance,
}
);
delete $c->stash->{Settings};
Expand Down
8 changes: 4 additions & 4 deletions lib/Libki/Schema/DB/Result/Job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ __PACKAGE__->table("jobs");

=head2 data

data_type: 'longtext'
data_type: 'mediumtext'
is_nullable: 1

=head2 taken
Expand Down Expand Up @@ -110,7 +110,7 @@ __PACKAGE__->add_columns(
"type",
{ data_type => "varchar", is_nullable => 0, size => 191 },
"data",
{ data_type => "longtext", is_nullable => 1 },
{ data_type => "mediumtext", is_nullable => 1 },
"taken",
{ data_type => "varchar", is_nullable => 1, size => 191 },
"status",
Expand Down Expand Up @@ -149,8 +149,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");


# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-04-27 09:23:45
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:D2SKTWMAT1jwHSux1UE7qQ
# Created by DBIx::Class::Schema::Loader v0.07053 @ 2026-02-11 10:59:52
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:slA0TWq4fcyY7kqYTEuk9g

__PACKAGE__->load_components('InflateColumn::Serializer');
__PACKAGE__->add_columns(
Expand Down
8 changes: 4 additions & 4 deletions lib/Libki/Schema/DB/Result/LoginSession.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ __PACKAGE__->table("login_sessions");

=head2 session_data

data_type: 'longtext'
data_type: 'mediumtext'
is_nullable: 1

=head2 expires
Expand All @@ -71,7 +71,7 @@ __PACKAGE__->add_columns(
"id",
{ data_type => "char", is_nullable => 0, size => 72 },
"session_data",
{ data_type => "longtext", is_nullable => 1 },
{ data_type => "mediumtext", is_nullable => 1 },
"expires",
{ data_type => "integer", is_nullable => 1 },
);
Expand All @@ -89,8 +89,8 @@ __PACKAGE__->add_columns(
__PACKAGE__->set_primary_key("id");


# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-04-27 09:23:45
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:m+OJsvQRg7FrVcbnVJwBxg
# Created by DBIx::Class::Schema::Loader v0.07053 @ 2026-02-11 10:59:52
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6VF4JGAZI2UkY4knbkR/XQ


# You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down
8 changes: 4 additions & 4 deletions lib/Libki/Schema/DB/Result/Message.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ __PACKAGE__->table("messages");

=head2 content

data_type: 'longtext'
data_type: 'mediumtext'
is_nullable: 0

=cut
Expand All @@ -83,7 +83,7 @@ __PACKAGE__->add_columns(
"user_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"content",
{ data_type => "longtext", is_nullable => 0 },
{ data_type => "mediumtext", is_nullable => 0 },
);

=head1 PRIMARY KEY
Expand Down Expand Up @@ -116,8 +116,8 @@ __PACKAGE__->belongs_to(
);


# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-04-27 09:23:45
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hn49kjZD6Hzpl6FiOXBHww
# Created by DBIx::Class::Schema::Loader v0.07053 @ 2026-02-11 10:59:52
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CuV5c2ONcc5nZazLSr+QhQ


# You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down
8 changes: 4 additions & 4 deletions lib/Libki/Schema/DB/Result/PrintFile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ __PACKAGE__->table("print_files");

=head2 filename

data_type: 'longtext'
data_type: 'mediumtext'
is_nullable: 0

=head2 content_type
Expand Down Expand Up @@ -141,7 +141,7 @@ __PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"filename",
{ data_type => "longtext", is_nullable => 0 },
{ data_type => "mediumtext", is_nullable => 0 },
"content_type",
{ data_type => "varchar", is_nullable => 1, size => 191 },
"data",
Expand Down Expand Up @@ -246,8 +246,8 @@ __PACKAGE__->belongs_to(
);


# Created by DBIx::Class::Schema::Loader v0.07051 @ 2023-07-11 07:35:11
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9IRAjpODFDD7mIKVnM/Jgg
# Created by DBIx::Class::Schema::Loader v0.07053 @ 2026-02-11 10:59:52
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kc5pJ/hX1R5YWDHG53PgHQ


# You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down
Loading
Loading