diff --git a/TODO b/TODO index 3ed8a5c..1afa2f0 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,5 @@ +PDF header fix + User FavouriteForumTopics @@ -28,7 +30,9 @@ PollAnswer Article check if public UserForumViewed - it should contain records that show the last viewed post in each forum topic + User + ForumTopic + timestamp of last visit BlogPost id @@ -55,17 +59,6 @@ ForumPost last edit reason edit count -Library - id - owner - author - title - year - borrowable - borrowed by - borrower returned - commentable - Event last edited by last edited timestamp diff --git a/app/AppKernel.php b/app/AppKernel.php index b915e32..f7a85e0 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -23,6 +23,7 @@ class AppKernel extends Kernel new Ivory\CKEditorBundle\IvoryCKEditorBundle(), new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), new Io\TcpdfBundle\IoTcpdfBundle(), + new FOS\JsRoutingBundle\FOSJsRoutingBundle(), // Own bundles new KekRozsak\FrontBundle\KekRozsakFrontBundle(), new KekRozsak\SecurityBundle\KekRozsakSecurityBundle(), diff --git a/app/DoctrineMigrations/Version20120801224509.php b/app/DoctrineMigrations/Version20120801224509.php new file mode 100644 index 0000000..4899b4a --- /dev/null +++ b/app/DoctrineMigrations/Version20120801224509.php @@ -0,0 +1,24 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("CREATE TABLE books (id INT AUTO_INCREMENT NOT NULL, author VARCHAR(100) NOT NULL, title VARCHAR(100) NOT NULL, year INT NOT NULL, commentable TINYINT(1) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB"); + $this->addSql("CREATE TABLE book_copies (id INT AUTO_INCREMENT NOT NULL, book_id INT NOT NULL, owner_id INT NOT NULL, borrower_id INT DEFAULT NULL, owner_comment LONGTEXT NOT NULL, borrowable TINYINT(1) NOT NULL, borrower_returned TINYINT(1) NOT NULL, INDEX IDX_F0A8D81116A2B381 (book_id), INDEX IDX_F0A8D8117E3C61F9 (owner_id), UNIQUE INDEX UNIQ_F0A8D81111CE312B (borrower_id), UNIQUE INDEX UNIQ_F0A8D8117E3C61F916A2B381 (owner_id, book_id), PRIMARY KEY(id)) ENGINE = InnoDB"); + $this->addSql("ALTER TABLE book_copies ADD CONSTRAINT FK_F0A8D81116A2B381 FOREIGN KEY (book_id) REFERENCES books (id)"); + $this->addSql("ALTER TABLE book_copies ADD CONSTRAINT FK_F0A8D8117E3C61F9 FOREIGN KEY (owner_id) REFERENCES users (id)"); + $this->addSql("ALTER TABLE book_copies ADD CONSTRAINT FK_F0A8D81111CE312B FOREIGN KEY (borrower_id) REFERENCES users (id)"); + } + + public function down(Schema $schema) + { + // this down() migration is autogenerated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE book_copies DROP FOREIGN KEY FK_F0A8D81116A2B381"); + $this->addSql("DROP TABLE books"); + $this->addSql("DROP TABLE book_copies"); + } +} diff --git a/app/DoctrineMigrations/Version20120806165106.php b/app/DoctrineMigrations/Version20120806165106.php new file mode 100644 index 0000000..14c2dec --- /dev/null +++ b/app/DoctrineMigrations/Version20120806165106.php @@ -0,0 +1,34 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("CREATE TABLE book_would_borrow (book_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_7ED804D216A2B381 (book_id), INDEX IDX_7ED804D2A76ED395 (user_id), PRIMARY KEY(book_id, user_id)) ENGINE = InnoDB"); + $this->addSql("CREATE TABLE book_would_buy (book_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_67D6BB5216A2B381 (book_id), INDEX IDX_67D6BB52A76ED395 (user_id), PRIMARY KEY(book_id, user_id)) ENGINE = InnoDB"); + $this->addSql("ALTER TABLE book_would_borrow ADD CONSTRAINT FK_7ED804D216A2B381 FOREIGN KEY (book_id) REFERENCES books (id) ON DELETE CASCADE"); + $this->addSql("ALTER TABLE book_would_borrow ADD CONSTRAINT FK_7ED804D2A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE"); + $this->addSql("ALTER TABLE book_would_buy ADD CONSTRAINT FK_67D6BB5216A2B381 FOREIGN KEY (book_id) REFERENCES books (id) ON DELETE CASCADE"); + $this->addSql("ALTER TABLE book_would_buy ADD CONSTRAINT FK_67D6BB52A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE"); + } + + public function down(Schema $schema) + { + // this down() migration is autogenerated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("DROP TABLE book_would_borrow"); + $this->addSql("DROP TABLE book_would_buy"); + } +} diff --git a/app/DoctrineMigrations/Version20120806165716.php b/app/DoctrineMigrations/Version20120806165716.php new file mode 100644 index 0000000..8a30627 --- /dev/null +++ b/app/DoctrineMigrations/Version20120806165716.php @@ -0,0 +1,28 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE book_copies ADD buyable TINYINT(1) NOT NULL"); + } + + public function down(Schema $schema) + { + // this down() migration is autogenerated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE book_copies DROP buyable"); + } +} diff --git a/app/DoctrineMigrations/Version20120808111846.php b/app/DoctrineMigrations/Version20120808111846.php new file mode 100644 index 0000000..85e5f86 --- /dev/null +++ b/app/DoctrineMigrations/Version20120808111846.php @@ -0,0 +1,28 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE book_copies CHANGE owner_comment owner_comment LONGTEXT DEFAULT NULL"); + } + + public function down(Schema $schema) + { + // this down() migration is autogenerated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + $this->addSql("ALTER TABLE book_copies CHANGE owner_comment owner_comment LONGTEXT NOT NULL"); + } +} diff --git a/app/Resources/views/main_template.html.twig b/app/Resources/views/main_template.html.twig index 5482f8d..362cea4 100644 --- a/app/Resources/views/main_template.html.twig +++ b/app/Resources/views/main_template.html.twig @@ -11,14 +11,32 @@ + + + {% block additional_js %}{% endblock %}
+
+ Szerző: {{ book.author }}
+ Cím: {{ book.title }}
+ Kiadás éve: {{ book.year }}
+
+ Nekem van {{ book.usersCopies(app.user)|length }}, ebből kölcsön van adva X.
+ A teljes közösségnek összesen {{ book.copies|length }} példánya van.
+ Kölcsönkérhető {{ book.copiesBorrowable|length }} példány, ebből {{ book.copiesBorrowedByUser(app.user)|length }} nálam van.
+
+{% if book.usersCopies(app.user)|length == 0 %} + [Eladtam valakinek a körben] +#} +{% if book.usersCopiesBorrowable(app.user)|length == 0 %} + +{% else %} + +{% endif %} +{% endif %} + +{% if book.usersCopies(app.user)|length > 0 %} +{% if book.usersCopiesBuyable(app.user)|length == 0 %} + +{% else %} + +{% endif %} +{% endif %} + +{% if book.copiesBorrowedByUser(app.user)|length == 0 and book.usersCopies(app.user)|length == 0 and not book.userWouldBorrow(app.user) %} + +{% endif %} + +{% if book.usersCopies(app.user)|length == 0 and not book.userWouldBuy(app.user) %} + +{% endif %} +
+{% if book.wouldBuy|length > 0 %} + +{% else %} + +{# TODO +
+ Ők szeretnének egyet kölcsönkérni:
+
+ Ők szeretnének venni egyet:
+
Szerző | +Cím | +Év | +Összes | +Kölcsönözhető | +Saját | +Nálam (Vissza) | +
{{ book.author }} | +{{ book.title }} | +{{ book.year }} | +{{ book.copies|length }} | +{{ book.copiesBorrowable|length }} | +{{ book.usersCopies(app.user)|length }} | +{{ book.copiesBorrowedByUser(app.user)|length }} ({{ book.copiesBorrowedReturnedByUser(app.user)|length }}) | +