Skip to content

Commit

Permalink
Large changes to increase user-friendliness (including installer):
Browse files Browse the repository at this point in the history
Introduces a procedure for installation and upgrades (includes changes to the database structure, configuration file and .htaccess).
Support for PostgreSQL (includes changes to the database structure).
Support for webcron.
Some small quality of life fixes:
- Sort by the most recent transaction when debt is identical
- Better introduction text on landing page
- Clear up text describing the licenses of Bootstrap and Font Awesome
- Improve URL handling by merging reminderurl and base_url configuration
- Favicon ico file fallback
- More semantic link for home icon
  • Loading branch information
bertvandepoel committed Jan 16, 2021
1 parent e3891d3 commit 7964df7
Show file tree
Hide file tree
Showing 26 changed files with 739 additions and 133 deletions.
14 changes: 9 additions & 5 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_URI} changelog.txt$
RewriteRule ^ index.php [L]
</IfModule>
73 changes: 62 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Tabby is a tool I made for myself due to lack of practical and unannoying tools to manage debt and remind people about it. Since existing solutions require accounts for people to even see how much you owe, or have other annoying requirements or missing features, I created Tabby with the idea that it would serve all of my needs and be as enjoyable for my debtors as possible (I was mostly just tired of reminding people to pay back their meals).

While initially developing Tabby as mostly a quick little script, I somehow managed to develop it in full. So since it works surprisingly well and has a bunch of features, I ended up FOSSing it. It's something I very much believe in ideologically, and I think it might be useful to others.
While initially developing Tabby as mostly a quick little script, I somehow managed to develop it in full. So since it works surprisingly well and has a bunch of features, I ended up FOSSing it. It's something I very much believe in ideologically, and I think it might be useful to others. From time to time, I still add new features to Tabby to make it more convenient for me or if a friend (or a user on GitHub) requests a specific feature that also makes sense to me.

## Features

Expand All @@ -13,28 +13,79 @@ While initially developing Tabby as mostly a quick little script, I somehow mana
* Track debt based on activities
* Track credit separate from whether a specific debt was repaid or not (so people with open credit are just fine)
* Reminds users to check their bank account and then ask Tabby to send reminders
* Probably GDPR-compliant, I guess?
* In spirit of the GDPR, as little information is required as possible.
* Adorable logo
* Probably more things, not too sure what to write here
* ... and more (I'm probably forgetting to mention some neat stuff, so check out the screenshots below for sure!)

## Screenshots

### Landing page
This page is displayed when a user is not logged in. It features some basic information about Tabby, as well as a login form, link to a registration form, and an easy way to request a token link to check your debt without an account.
![screenshot landing page](/screenshots/screenshot_1_landing.png?raw=true)

### Installation form
Since version 1.1, Tabby has a simple installation form where you enter your database credentials, email preferences and application settings. The database tables as well as the configuration file are created automatically.
![screenshot installation form](/screenshots/screenshot_2_install.png?raw=true)

### Overview of debt (or credit) of all your contacts
This is the page you see after logging in to Tabby. It gives an overview of what each of your contacts owes you and from what. Tabby displays which debts are (fully or partially) unpaid, as well as credits. A total is displayed at the bottom of each contact's box. You can easily enter wire transfers or cash you reveived through the small forms. Buttons are available for most actions you may need to perform.
![screenshot overview of debt by people](/screenshots/screenshot_3_people.png?raw=true)

### Overview of debt by activity
This page gives an overview of each activity you've added to Tabby. For those who haven't fully repaid their debt for that specific activity, the number is marked with a colour. You can also easily add extra contacts for a specific activity or change the numbers if you've made a mistake.
![screenshot overview of debt by people](/screenshots/screenshot_4_activities.png?raw=true)

### Reminder page
It's super easy to send a reminder with Tabby. You can pick whether you want to email everyone with debt or just a specific person. You can also add an optional message to make the reminder a bit more personal.
![screenshot reminder page](/screenshots/screenshot_5_reminder.png?raw=true)

## Requirements

* PHP 7.2 or up, mostly works fine with PHP 5.5.9 except for email functionality
* MySQL (may also work with PostgreSQL)
* Cron
* MySQL or PostgreSQL
* Working mail setup on the webserver
* Cron is advised but webcron fallback is available

## Installation

* Clone this repo to the right location or copy/transfer it there
* Edit config.php to reflect your situation
* Import db.sql into your empty database
* Manually add an entry to the users table for your admin account, the password should be a PHP password_hash. I should probably automate this somehow.
* Setup a daily cronjob for cron.php
### Released version

* Download the [latest release](https://github.com/bertvandepoel/tabby/releases/latest) from GitHub releases.
* Unpack and upload the file to your server or hosting space.
* Visit the corresponding URL, Tabby will automatically display the installation form.
* Enter the database credentials (create them if you don't have them yet).
* Enter email and application settings.
* After confirming installation, the configuration will be written to a file.
* If no write permissions are available, the contents of the configuration file are displayed. Create config.php locally with those contents and upload it to the correct folder.
* When you're not using webcron, correctly install a cronjob using the displayed example as basis.
* If not using Apache or if mod_rewrite and/or .htaccess aren't available, you may need to configure correct mapping to index.php and redirecting of the changelog.
* You can now start using your Tabby installation. Log in with your account, then add people to register debt from activities for them.

### Git version

Keep in mind that code may be committed to git that isn't ready for a full release.

* Clone this repo to the right location or copy/transfer it there.
* Visit the corresponding URL, Tabby will automatically display the installation form.
* Enter the database credentials (create them if you don't have them yet).
* Enter email and application settings.
* After confirming installation, the configuration will be written to a file.
* If no write permissions are available, the contents of the configuration file are displayed. Create config.php locally with those contents and upload it to the correct folder.
* When you're not using webcron, correctly install a cronjob using the displayed example as basis.
* If not using Apache or if mod_rewrite and/or .htaccess aren't available, you may need to configure correct mapping to index.php and redirecting of the changelog.
* You can now start using your Tabby installation. Log in with your account, then add people to register debt from activities for them.

## Upgrading

If you are using git, pull the latest version and then checkout the tag of the version you're upgrading to. If you are using releases, simply download the right files and overwrite your current directory (or move over config.php). When all the files are in place, visit upgrade.php or run it from the command line to perform database schema upgrade (if required). Follow any supplementary instructions upgrade.php displays.

## Changelog

A simplified changelog is available in the [changelog.txt](changelog.txt) file.

## License

This project is licensed under the AGPL license - see the [LICENSE](LICENSE) file for details
This project is licensed under the AGPL license - see the [LICENSE](LICENSE) file for details.

## Acknowledgements

Expand Down
28 changes: 28 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version 1.1 - commit 0fbfdb027c944c602f5ae96d94855ffae92440f9

Introduces a procedure for installation and upgrades (includes changes to the database structure, configuration file and .htaccess).
Support for PostgreSQL (includes changes to the database structure).
Support for webcron.
Some small quality of life fixes:
- Sort by the most recent transaction when debt is identical
- Better introduction text on landing page
- Clear up text describing the licenses of Bootstrap and Font Awesome
- Improve URL handling by merging reminderurl and base_url configuration
- Favicon ico file fallback
- More semantic link for home icon

version 1.0.1 - commit 75ab9c8d0f69938240146989b6832d4c20a5ee65

Some small quality of life fixes:
- When logged in, redirect any token link to "My debt"
- Add a "Today" button to enter the current date in forms
- Fix sorting issue in detailed overview of a user
- Mention total debt in new activity emails, not just the newly added debt
- Favicons
- Hide unnecessary layout elements on the chrome/chromium date picker
-

version 1.0 - commit 67b554a08bbed216423b8d968c67ddfe8169df2a

Very first version of Tabby.
Includes all core features of Tabby as well as the striking and user-friendly interface.
19 changes: 0 additions & 19 deletions config.php

This file was deleted.

38 changes: 24 additions & 14 deletions cron.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
<?php

include('config.php');
include('resources/users.php');
include('resources/transactions.php');
include_once('config.php');
include_once('resources/init.php');
include_once('resources/users.php');
include_once('resources/transactions.php');

$users = get_users_by_reminddif($days);
$check = $db->prepare('SELECT value FROM config WHERE id=?');
$check->execute(array('cron'));
$result = $check->fetch(PDO::FETCH_ASSOC);

foreach($users as $user) {
if(user_have_debtors_in_debt($user['email'])) {
if(is_null($user['reminddate'])) {
$message = "Hi " . $user['name'] . ",\r\n\r\nIt seems you've never sent any reminders on Tabby. Since some people still have an open debt with you, it's probably best if you check your bank account, update any information on Tabby and then sent out new reminders if required.\r\n\r\nYou can get started straight away at " . $reminderurl . ".\r\n\r\nTabby will remind you every " . $days . " days as long as there is open debt.\r\n\r\nHave a nice day!\r\n\r\nTabby";
if(date('Y-m-d') !== date('Y-m-d', $result['value'])){
$users = get_users_by_reminddif($days);

foreach($users as $user) {
if(user_have_debtors_in_debt($user['email'])) {
if(is_null($user['reminddate'])) {
$message = "Hi " . $user['name'] . ",\r\n\r\nIt seems you've never sent any reminders on Tabby. Since some people still have an open debt with you, it's probably best if you check your bank account, update any information on Tabby and then sent out new reminders if required.\r\n\r\nYou can get started straight away at " . $base_url . ".\r\n\r\nTabby will remind you every " . $days . " days as long as there is open debt.\r\n\r\nHave a nice day!\r\n\r\nTabby";
}
else {
$message = "Hi " . $user['name'] . ",\r\n\r\nIt seems you haven't sent any new reminders on Tabby since " . date('d M Y', strtotime($user['reminddate'])) . ". Since some people still have an open debt with you, it's probably best if you check your bank account, update any information on Tabby and then sent out new reminders if required.\r\n\r\nYou can get started straight away at " . $base_url . ".\r\n\r\nTabby will remind you every " . $days . " days as long as there is open debt.\r\n\r\nHave a nice day!\r\n\r\nTabby";
}

$headers = 'From: ' . $application_email;
mail($user['email'], 'Tabby: time to send reminders', $message, $headers);
}
else {
$message = "Hi " . $user['name'] . ",\r\n\r\nIt seems you haven't sent any new reminders on Tabby since " . date('d M Y', strtotime($user['reminddate'])) . ". Since some people still have an open debt with you, it's probably best if you check your bank account, update any information on Tabby and then sent out new reminders if required.\r\n\r\nYou can get started straight away at " . $reminderurl . ".\r\n\r\nTabby will remind you every " . $days . " days as long as there is open debt.\r\n\r\nHave a nice day!\r\n\r\nTabby";
}

$headers = 'From: ' . $application_email;
mail($user['email'], 'Tabby: time to send reminders', $message, $headers);
}

$update = $db->prepare('UPDATE config SET value=? WHERE id=?');
$update->execute(array(strtotime('now'), 'cron'));
}
64 changes: 36 additions & 28 deletions db.sql → db_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,60 @@ CREATE TABLE `users` (
`iban` varchar(34) NOT NULL,
`reminddate` date NULL,
PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
);

CREATE TABLE `tokens` (
`email` varchar(50) NOT NULL,
`token` varchar(25) NOT NULL,
PRIMARY KEY (`email`),
UNIQUE KEY `token` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
UNIQUE KEY (`token`)
);

CREATE TABLE `activities` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(250) NOT NULL,
`user` varchar(50) NOT NULL,
`owner` varchar(50) NOT NULL,
`date` date NOT NULL,
PRIMARY KEY (`id`),
KEY `user` (`user`),
FOREIGN KEY (`user`) REFERENCES users(email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
KEY (`owner`),
FOREIGN KEY (`owner`) REFERENCES users(email)
);

CREATE TABLE `debtors` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`user` varchar(50) NOT NULL,
`owner` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
KEY `user` (`user`),
KEY `email` (`email`),
FOREIGN KEY (`user`) REFERENCES users(email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
KEY (`owner`),
KEY (`email`),
FOREIGN KEY (`owner`) REFERENCES users(email)
);

CREATE TABLE `credits` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`debtor` int(11) NOT NULL,
`id` int NOT NULL AUTO_INCREMENT,
`debtor` int NOT NULL,
`comment` varchar(250) NOT NULL,
`amount` int(8) NOT NULL,
`amount` int NOT NULL,
`date` date NOT NULL,
PRIMARY KEY (`id`),
KEY `debtor` (`debtor`),
KEY (`debtor`),
FOREIGN KEY (`debtor`) REFERENCES debtors(id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
);


CREATE TABLE `debts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`activity` int(11) NOT NULL,
`debtor` int(11) NOT NULL,
`id` int NOT NULL AUTO_INCREMENT,
`activity` int NOT NULL,
`debtor` int NOT NULL,
`comment` varchar(250) DEFAULT NULL,
`amount` int(8) NOT NULL,
`amount` int NOT NULL,
PRIMARY KEY (`id`),
KEY `debtor` (`debtor`),
KEY `activity` (`activity`),
KEY (`debtor`),
KEY (`activity`),
FOREIGN KEY (`debtor`) REFERENCES debtors(id),
FOREIGN KEY (`activity`) REFERENCES activities(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
);


CREATE TABLE `pending_users` (
Expand All @@ -69,5 +69,13 @@ CREATE TABLE `pending_users` (
`confirmation` varchar(25) NOT NULL,
`datetime` datetime NOT NULL,
PRIMARY KEY (`email`),
UNIQUE KEY `confirmation` (`confirmation`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
UNIQUE KEY (`confirmation`)
);

CREATE TABLE `config` (
`id` varchar(50) NOT NULL,
`value` TEXT NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `config` VALUES ('schema', '2');
INSERT INTO `config` VALUES ('cron', '0');
85 changes: 85 additions & 0 deletions db_postgresql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
CREATE TABLE "users" (
"email" varchar(50) NOT NULL,
"name" varchar(50) NOT NULL,
"password" varchar(255) NOT NULL,
"iban" varchar(34) NOT NULL,
"reminddate" date NULL,
PRIMARY KEY ("email")
);


CREATE TABLE "tokens" (
"email" varchar(50) NOT NULL,
"token" varchar(25) NOT NULL,
PRIMARY KEY ("email"),
UNIQUE ("token")
);


CREATE TABLE "activities" (
"id" serial,
"name" varchar(250) NOT NULL,
"owner" varchar(50) NOT NULL,
"date" date NOT NULL,
PRIMARY KEY ("id"),
FOREIGN KEY ("owner") REFERENCES users(email)
);
CREATE INDEX ON "activities" ("owner");


CREATE TABLE "debtors" (
"id" serial,
"name" varchar(50) NOT NULL,
"email" varchar(50) NOT NULL,
"owner" varchar(50) NOT NULL,
PRIMARY KEY ("id"),
FOREIGN KEY ("owner") REFERENCES users(email)
);
CREATE INDEX ON "debtors" ("owner");
CREATE INDEX ON "debtors" ("email");


CREATE TABLE "credits" (
"id" serial,
"debtor" integer NOT NULL,
"comment" varchar(250) NOT NULL,
"amount" integer NOT NULL,
"date" date NOT NULL,
PRIMARY KEY ("id"),
FOREIGN KEY ("debtor") REFERENCES debtors(id)
);
CREATE INDEX ON "credits" ("debtor");


CREATE TABLE "debts" (
"id" serial,
"activity" integer NOT NULL,
"debtor" integer NOT NULL,
"comment" varchar(250) DEFAULT NULL,
"amount" integer NOT NULL,
PRIMARY KEY ("id"),
FOREIGN KEY ("debtor") REFERENCES debtors(id),
FOREIGN KEY ("activity") REFERENCES activities(id) ON DELETE CASCADE
);
CREATE INDEX ON "debts" ("debtor");
CREATE INDEX ON "debts" ("activity");


CREATE TABLE "pending_users" (
"email" varchar(50) NOT NULL,
"name" varchar(50) NOT NULL,
"password" varchar(255) NOT NULL,
"iban" varchar(34) NOT NULL,
"confirmation" varchar(25) NOT NULL,
"datetime" timestamp NOT NULL,
PRIMARY KEY ("email"),
UNIQUE ("confirmation")
);

CREATE TABLE "config" (
"id" varchar(50) NOT NULL,
"value" TEXT NOT NULL,
PRIMARY KEY ("id")
);
INSERT INTO "config" VALUES ('schema', '2');
INSERT INTO "config" VALUES ('cron', '0');
Binary file added favicon/favicon.ico
Binary file not shown.
Loading

0 comments on commit 7964df7

Please sign in to comment.