Compare commits
26
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37462e4646 | ||
|
|
fbee23c022 | ||
|
|
facd5bc9c0 | ||
|
|
1bf738be1c | ||
|
|
d9489f2558 | ||
|
|
e93a5ff3a9 | ||
|
|
69bc2630fd | ||
|
|
bad9c6ea51 | ||
|
|
a495be6bb2 | ||
|
|
986f422824 | ||
|
|
bfcd04c701 | ||
|
|
0cf6f231a3 | ||
|
|
77f8d9f87a | ||
|
|
ee058aa3b3 | ||
|
|
f1031c14df | ||
|
|
98e3627f29 | ||
|
|
22e46cb841 | ||
|
|
7475be603c | ||
|
|
06577df0ad | ||
|
|
048681e8ad | ||
|
|
975d0495a8 | ||
|
|
09f384fce0 | ||
|
|
53374dfdfc | ||
|
|
82bd51e6f0 | ||
|
|
8c6a70b0be | ||
|
|
b723189fda |
@@ -8,3 +8,11 @@
|
|||||||
/var/
|
/var/
|
||||||
/vendor/
|
/vendor/
|
||||||
###< symfony/framework-bundle ###
|
###< symfony/framework-bundle ###
|
||||||
|
|
||||||
|
# Draw.io backup file.
|
||||||
|
*bkp
|
||||||
|
|
||||||
|
###> symfony/asset-mapper ###
|
||||||
|
/public/assets/
|
||||||
|
/assets/vendor/
|
||||||
|
###< symfony/asset-mapper ###
|
||||||
|
|||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"php.suggest.basic": false,
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.formatOnSaveMode": "modificationsIfAvailable"
|
||||||
|
}
|
||||||
+9
-2
@@ -84,11 +84,18 @@ RUN set -eux; \
|
|||||||
|
|
||||||
# copy sources
|
# copy sources
|
||||||
COPY --link . ./
|
COPY --link . ./
|
||||||
RUN rm -Rf frankenphp/
|
|
||||||
|
|
||||||
|
# Remove development data.
|
||||||
|
RUN rm -Rf frankenphp/ \
|
||||||
|
rm -Rf .gitea/ \
|
||||||
|
rm -Rf .vscode/ \
|
||||||
|
rm -Rf public/images
|
||||||
|
|
||||||
|
# Setup application.
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
mkdir -p var/cache var/log; \
|
mkdir -p var/cache var/log; \
|
||||||
composer dump-autoload --classmap-authoritative --no-dev; \
|
composer dump-autoload --classmap-authoritative --no-dev; \
|
||||||
composer dump-env prod; \
|
composer dump-env prod; \
|
||||||
composer run-script --no-dev post-install-cmd; \
|
composer run-script --no-dev post-install-cmd; \
|
||||||
chmod +x bin/console; sync;
|
chmod +x bin/console; sync; \
|
||||||
|
php bin/console asset-map:compile
|
||||||
|
|||||||
@@ -1,19 +1,661 @@
|
|||||||
Copyright (c) Fabien Potencier
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
in the Software without restriction, including without limitation the rights
|
of this license document, but changing it is not allowed.
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is furnished
|
|
||||||
to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
Preamble
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
software and other kinds of works, specifically designed to ensure
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
cooperation with the community in the case of network server software.
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
The licenses for most software and other practical works are designed
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
to take away your freedom to share and change the works. By contrast,
|
||||||
THE SOFTWARE.
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
Developers that use our General Public Licenses protect your rights
|
||||||
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
|
you this License which gives you legal permission to copy, distribute
|
||||||
|
and/or modify the software.
|
||||||
|
|
||||||
|
A secondary benefit of defending all users' freedom is that
|
||||||
|
improvements made in alternate versions of the program, if they
|
||||||
|
receive widespread use, become available for other developers to
|
||||||
|
incorporate. Many developers of free software are heartened and
|
||||||
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
|
The GNU Affero General Public License is designed specifically to
|
||||||
|
ensure that, in such cases, the modified source code becomes available
|
||||||
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
|
An older license, called the Affero General Public License and
|
||||||
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
|
this license.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
SomniaRooms - A room booking platform.
|
||||||
|
Copyright (C) 2024 - Daniel García
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published
|
||||||
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If your software can interact with users remotely through a computer
|
||||||
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for the
|
||||||
|
specific requirements.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
@@ -9,31 +9,96 @@ Powered by:
|
|||||||
## Commands:
|
## Commands:
|
||||||
|
|
||||||
Build containers:
|
Build containers:
|
||||||
```
|
```bash
|
||||||
docker compose build --no-cache
|
docker compose build --no-cache
|
||||||
```
|
```
|
||||||
|
|
||||||
Start Containers:
|
Start Containers:
|
||||||
```
|
```bash
|
||||||
docker compose up --pull always -d --wait
|
docker compose up --pull always -d --wait
|
||||||
docker compose --env-file .\.env.local up -d --wait
|
docker compose --env-file .\.env.local up -d --wait
|
||||||
```
|
```
|
||||||
|
|
||||||
Stop containers
|
Stop containers
|
||||||
```
|
```bash
|
||||||
docker compose down --remove-orphans
|
docker compose down --remove-orphans
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To use xdebug in VSCode you may need to configure some environment vars. A .env file (`.env.local`) can be used as:
|
||||||
|
```shell
|
||||||
|
XDEBUG_MODE=develop,debug
|
||||||
|
XDEBUG_DISCOVER_CLIENT_HOST=1
|
||||||
|
XDEBUG_IDEKEY=docker
|
||||||
|
XDEBUG_LOG=/dev/stdout
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Prod:
|
### Prod:
|
||||||
|
|
||||||
You can use docker compose for prod or build and deploy a prod image.
|
When deploying to a production environment a production build should be used.
|
||||||
|
Then, deployment can be done as containers or using docker-compose.
|
||||||
|
|
||||||
**Build Prod image**
|
**Build Prod image**
|
||||||
|
|
||||||
|
To build a production image:
|
||||||
```
|
```
|
||||||
docker build -t somniarooms:prod --target frankenphp_prod .
|
docker build -t somniarooms:prod --target frankenphp_prod .
|
||||||
```
|
```
|
||||||
|
|
||||||
**Deploy prod image**
|
**Deploy prod image**
|
||||||
|
|
||||||
|
You may use a env file to configure the SomniaRoom container:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
SERVER_NAME=localhost
|
||||||
|
DATABASE_URL=postgresql://app:!ChangeMe!@somniadb:5432/somniarooms?serverVersion=16&charset=utf8
|
||||||
|
APP_SECRET=MYSECRET
|
||||||
|
MERCURE_PUBLISHER_JWT_KEY=MYCADDY_MERCURE_JWT_SECRET
|
||||||
|
MERCURE_SUBSCRIBER_JWT_KEY=MYCADDY_MERCURE_JWT_SECRET
|
||||||
|
FRANKENPHP_CONFIG="" #-> Avoid using FrankenPHP workers, as don't play well with Easyadmin.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You need a database for using SomniaRooms.
|
||||||
|
To run one on a container you can use this that match this example config:
|
||||||
|
```bash
|
||||||
|
docker run -d --name somniarooms-db --hostname somniadb -p 5432:5432 --env=POSTGRES_DB=somniarooms --env=POSTGRES_PASSWORD=!ChangeMe! --env=POSTGRES_USER=app --env=PGDATA=/var/lib/postgresql/data --volume=somniarooms_db:/var/lib/postgresql/data --network somniarooms-network postgres:16-alpine
|
||||||
|
```
|
||||||
|
|
||||||
|
Then SomniaRooms can be deployed on a container (change --env-file value to the created file):
|
||||||
|
```bash
|
||||||
docker run -d -it -p 80:80 -p 443:443 --name somniarooms --env-file ./env.prod.local somniarooms:prod
|
docker run -d -it -p 80:80 -p 443:443 --name somniarooms --env-file ./env.prod.local somniarooms:prod
|
||||||
```
|
```
|
||||||
|
|
||||||
|
When deploying to prod is recomended to mount some directories as a docker volume or hostpath. This makes sure data is preserved after deleting the container.
|
||||||
|
- Image directory (`/app/public/images`)
|
||||||
|
|
||||||
|
If you are deploying your DB as a container, check the database docs and make sure database data won't be lost when updating or deleting the container. This example configuration store postgress data on a unnamed docket volume.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d -it -p 80:80 -p 443:443 --name somniarooms --env-file ./.env.prod.local --volume=somniarooms_images:/app/public/images:rw --network somniarooms-network somniarooms:prod
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want your app and DB to comunicate using it's hostname (like on this example) you should create a docker network.
|
||||||
|
```bash
|
||||||
|
docker network create somniarooms-network
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Running the app!
|
||||||
|
|
||||||
|
Go to the app address (`https://localhost`) and it will show Symfony welcome page (or a error when running on prod).
|
||||||
|
|
||||||
|
Go to addres `https://localhost/setup` to inicialize app users and data.
|
||||||
|
|
||||||
|
During setup you must configure the admin account.
|
||||||
|
If you check "Add example data" you will be redirected to example data setup.
|
||||||
|
Example data can be added anytime at `https://localhost/debug/exampleData`. There is needed to use a Superadmin account.
|
||||||
|
|
||||||
|
Then, you the admin panel is at `https://localhost/admin`
|
||||||
|
|
||||||
|
## Logs.
|
||||||
|
|
||||||
|
By default logs are saved to `/app/var/log` on an unamed container volume.
|
||||||
|
For development, `/app/var/log` directory is mounted to `./var/log` on the local filesystem.
|
||||||
|
|
||||||
|
This config can be overriden setting a different mount for `/app/var/log` when creating the containers.
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Welcome to your app's main JavaScript file!
|
||||||
|
*
|
||||||
|
* This file will be included onto the page via the importmap() Twig function,
|
||||||
|
* which should already be in your base.html.twig.
|
||||||
|
*/
|
||||||
|
import './styles/app.css';
|
||||||
|
|
||||||
|
console.log('SomniaRooms Admin Panel - Assets loaded! 🎉');
|
||||||
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 96 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bed"><path d="M2 4v16"/><path d="M2 8h18a2 2 0 0 1 2 2v10"/><path d="M2 17h20"/><path d="M6 8v9"/></svg>
|
||||||
|
After Width: | Height: | Size: 306 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bug-off"><path d="M15 7.13V6a3 3 0 0 0-5.14-2.1L8 2"/><path d="M14.12 3.88 16 2"/><path d="M22 13h-4v-2a4 4 0 0 0-4-4h-1.3"/><path d="M20.97 5c0 2.1-1.6 3.8-3.5 4"/><path d="m2 2 20 20"/><path d="M7.7 7.7A4 4 0 0 0 6 11v3a6 6 0 0 0 11.13 3.13"/><path d="M12 20v-8"/><path d="M6 13H2"/><path d="M3 21c0-2.1 1.7-3.9 3.8-4"/></svg>
|
||||||
|
After Width: | Height: | Size: 530 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check"><path d="M20 6 9 17l-5-5"/></svg>
|
||||||
|
After Width: | Height: | Size: 242 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-coffee"><path d="M10 2v2"/><path d="M14 2v2"/><path d="M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1"/><path d="M6 2v2"/></svg>
|
||||||
|
After Width: | Height: | Size: 371 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
|
||||||
|
After Width: | Height: | Size: 255 B |
@@ -0,0 +1,48 @@
|
|||||||
|
:root {
|
||||||
|
--main-border-radius: 5pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.container {
|
||||||
|
margin: 1em auto;
|
||||||
|
max-width: 800px;
|
||||||
|
width: 75%;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: var(--main-border-radius);
|
||||||
|
border: 1px solid #dad9d9;
|
||||||
|
box-shadow: 2px 2px 4px #dad9d9;
|
||||||
|
background-color: #F5F5F5;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-section {
|
||||||
|
position: relative;
|
||||||
|
margin-block: 10px;
|
||||||
|
padding-block: 8px;
|
||||||
|
margin-inline: auto;
|
||||||
|
width: 80%;
|
||||||
|
|
||||||
|
border: 1px solid #dad9d9;
|
||||||
|
border-radius: var(--main-border-radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
.msg-container {
|
||||||
|
max-width: 70%;
|
||||||
|
margin-inline: auto;
|
||||||
|
|
||||||
|
padding-block: 5px;
|
||||||
|
padding-inline: 8px;
|
||||||
|
|
||||||
|
border-radius: var(--main-border-radius);
|
||||||
|
border: 1px solid #dad9d9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.msg-error {
|
||||||
|
background-color: rgba(164, 0, 0, 0.5);
|
||||||
|
border-color: rgba(87, 0, 0, 0.75);
|
||||||
|
}
|
||||||
|
|
||||||
|
.msg-warn {
|
||||||
|
background-color: rgba(255, 234, 6, 0.5);
|
||||||
|
border-color: rgba(204, 187, 0, 0.75);
|
||||||
|
}
|
||||||
@@ -11,6 +11,8 @@ services:
|
|||||||
# If you develop on Mac or Windows you can remove the vendor/ directory
|
# If you develop on Mac or Windows you can remove the vendor/ directory
|
||||||
# from the bind-mount for better performance by enabling the next line:
|
# from the bind-mount for better performance by enabling the next line:
|
||||||
- /app/vendor
|
- /app/vendor
|
||||||
|
# On dev mount var to localfiles.
|
||||||
|
- ./var/log:/app/var/log
|
||||||
environment:
|
environment:
|
||||||
MERCURE_EXTRA_DIRECTIVES: demo
|
MERCURE_EXTRA_DIRECTIVES: demo
|
||||||
# See https://xdebug.org/docs/all_settings#mode
|
# See https://xdebug.org/docs/all_settings#mode
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
php:
|
php:
|
||||||
image: ${IMAGES_PREFIX:-}app-php
|
image: somniarooms
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
SERVER_NAME: ${SERVER_NAME:-localhost}, php:80
|
SERVER_NAME: ${SERVER_NAME:-localhost}, php:80
|
||||||
@@ -41,6 +41,7 @@ services:
|
|||||||
###> doctrine/doctrine-bundle ###
|
###> doctrine/doctrine-bundle ###
|
||||||
database:
|
database:
|
||||||
image: postgres:${POSTGRES_VERSION:-16}-alpine
|
image: postgres:${POSTGRES_VERSION:-16}-alpine
|
||||||
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: ${POSTGRES_DB:-app}
|
POSTGRES_DB: ${POSTGRES_DB:-app}
|
||||||
# You should definitely change the password in production
|
# You should definitely change the password in production
|
||||||
|
|||||||
+14
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "dgm/somnia-rooms",
|
"name": "dgm/somnia-rooms",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"license": "GPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"description": "A FOSS Hotel room booking system.",
|
"description": "A FOSS Hotel room booking system.",
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
@@ -14,21 +14,31 @@
|
|||||||
"doctrine/doctrine-migrations-bundle": "^3.3",
|
"doctrine/doctrine-migrations-bundle": "^3.3",
|
||||||
"doctrine/orm": "^3.1",
|
"doctrine/orm": "^3.1",
|
||||||
"easycorp/easyadmin-bundle": "^4.10",
|
"easycorp/easyadmin-bundle": "^4.10",
|
||||||
|
"nelmio/api-doc-bundle": "^4.30",
|
||||||
"nelmio/cors-bundle": "^2.4",
|
"nelmio/cors-bundle": "^2.4",
|
||||||
"phpdocumentor/reflection-docblock": "^5.4",
|
"phpdocumentor/reflection-docblock": "^5.4",
|
||||||
"phpstan/phpdoc-parser": "^1.28",
|
"phpstan/phpdoc-parser": "^1.28",
|
||||||
"runtime/frankenphp-symfony": "^0.2.0",
|
"runtime/frankenphp-symfony": "^0.2.0",
|
||||||
|
"symfony/asset": "7.0.*",
|
||||||
|
"symfony/asset-mapper": "7.0.*",
|
||||||
"symfony/console": "7.0.*",
|
"symfony/console": "7.0.*",
|
||||||
"symfony/dotenv": "7.0.*",
|
"symfony/dotenv": "7.0.*",
|
||||||
"symfony/flex": "^2",
|
"symfony/flex": "^2",
|
||||||
"symfony/form": "7.0.*",
|
"symfony/form": "7.0.*",
|
||||||
"symfony/framework-bundle": "7.0.*",
|
"symfony/framework-bundle": "7.0.*",
|
||||||
|
"symfony/mime": "7.0.*",
|
||||||
|
"symfony/monolog-bundle": "^3.10",
|
||||||
"symfony/property-access": "7.0.*",
|
"symfony/property-access": "7.0.*",
|
||||||
"symfony/property-info": "7.0.*",
|
"symfony/property-info": "7.0.*",
|
||||||
"symfony/runtime": "7.0.*",
|
"symfony/runtime": "7.0.*",
|
||||||
"symfony/security-bundle": "7.0.*",
|
"symfony/security-bundle": "7.0.*",
|
||||||
"symfony/serializer": "7.0.*",
|
"symfony/serializer": "7.0.*",
|
||||||
"symfony/yaml": "7.0.*"
|
"symfony/twig-bundle": "7.0.*",
|
||||||
|
"symfony/validator": "7.0.*",
|
||||||
|
"symfony/var-exporter": "7.0.4",
|
||||||
|
"symfony/yaml": "7.0.*",
|
||||||
|
"twig/extra-bundle": "^2.12|^3.0",
|
||||||
|
"twig/twig": "^2.12|^3.0"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"allow-plugins": {
|
"allow-plugins": {
|
||||||
@@ -61,7 +71,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"auto-scripts": {
|
"auto-scripts": {
|
||||||
"cache:clear": "symfony-cmd",
|
"cache:clear": "symfony-cmd",
|
||||||
"assets:install %PUBLIC_DIR%": "symfony-cmd"
|
"assets:install %PUBLIC_DIR%": "symfony-cmd",
|
||||||
|
"importmap:install": "symfony-cmd"
|
||||||
},
|
},
|
||||||
"post-install-cmd": [
|
"post-install-cmd": [
|
||||||
"@auto-scripts"
|
"@auto-scripts"
|
||||||
|
|||||||
Generated
+1064
-32
File diff suppressed because it is too large
Load Diff
@@ -10,4 +10,7 @@ return [
|
|||||||
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
|
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
|
||||||
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
|
EasyCorp\Bundle\EasyAdminBundle\EasyAdminBundle::class => ['all' => true],
|
||||||
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
|
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
|
||||||
|
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
|
||||||
|
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true],
|
||||||
|
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
framework:
|
||||||
|
asset_mapper:
|
||||||
|
# The paths to make available to the asset mapper.
|
||||||
|
paths:
|
||||||
|
- assets/
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
monolog:
|
||||||
|
channels:
|
||||||
|
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
|
||||||
|
|
||||||
|
when@dev:
|
||||||
|
monolog:
|
||||||
|
handlers:
|
||||||
|
main:
|
||||||
|
type: rotating_file
|
||||||
|
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||||
|
level: debug
|
||||||
|
channels: ["!event", "!doctrine"]
|
||||||
|
max_files: 0
|
||||||
|
doctrine:
|
||||||
|
type: rotating_file
|
||||||
|
path: "%kernel.logs_dir%/db_%kernel.environment%.log"
|
||||||
|
level: debug
|
||||||
|
channels: ["doctrine", "request"]
|
||||||
|
max_files: 10
|
||||||
|
# uncomment to get logging in your browser
|
||||||
|
# you may have to allow bigger header sizes in your Web server configuration
|
||||||
|
#firephp:
|
||||||
|
# type: firephp
|
||||||
|
# level: info
|
||||||
|
#chromephp:
|
||||||
|
# type: chromephp
|
||||||
|
# level: info
|
||||||
|
console:
|
||||||
|
type: console
|
||||||
|
process_psr_3_messages: false
|
||||||
|
channels: ["!event", "!doctrine", "!console"]
|
||||||
|
|
||||||
|
when@test:
|
||||||
|
monolog:
|
||||||
|
handlers:
|
||||||
|
main:
|
||||||
|
type: fingers_crossed
|
||||||
|
action_level: error
|
||||||
|
handler: nested
|
||||||
|
excluded_http_codes: [404, 405]
|
||||||
|
channels: ["!event"]
|
||||||
|
nested:
|
||||||
|
type: stream
|
||||||
|
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||||
|
level: debug
|
||||||
|
|
||||||
|
when@prod:
|
||||||
|
monolog:
|
||||||
|
handlers:
|
||||||
|
main:
|
||||||
|
type: fingers_crossed
|
||||||
|
action_level: error
|
||||||
|
handler: nested
|
||||||
|
excluded_http_codes: [404, 405]
|
||||||
|
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
|
||||||
|
nested:
|
||||||
|
type: stream
|
||||||
|
path: php://stderr
|
||||||
|
level: debug
|
||||||
|
formatter: monolog.formatter.json
|
||||||
|
console:
|
||||||
|
type: console
|
||||||
|
process_psr_3_messages: false
|
||||||
|
channels: ["!event", "!doctrine"]
|
||||||
|
deprecation:
|
||||||
|
type: stream
|
||||||
|
channels: [deprecation]
|
||||||
|
path: php://stderr
|
||||||
|
formatter: monolog.formatter.json
|
||||||
|
logfile:
|
||||||
|
type: rotating_file
|
||||||
|
path: "%kernel.logs_dir%/%kernel.environment%.log"
|
||||||
|
level: info
|
||||||
|
channels: ["!event"]
|
||||||
|
max_files: 60
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
nelmio_api_doc:
|
||||||
|
documentation:
|
||||||
|
info:
|
||||||
|
title: SomniaRooms
|
||||||
|
description: A FOSS Hotel room booking system.
|
||||||
|
version: 1.0.0
|
||||||
|
areas: # to filter documented areas
|
||||||
|
path_patterns:
|
||||||
|
- ^/api(?!/doc$) # Accepts routes under /api except /api/doc
|
||||||
@@ -35,6 +35,7 @@ security:
|
|||||||
# Note: Only the *first* access control that matches will be used
|
# Note: Only the *first* access control that matches will be used
|
||||||
access_control:
|
access_control:
|
||||||
- { path: ^/admin, roles: ROLE_ADMIN }
|
- { path: ^/admin, roles: ROLE_ADMIN }
|
||||||
|
- { path: ^/debug, roles: ROLE_SUPERADMIN }
|
||||||
# - { path: ^/profile, roles: ROLE_USER }
|
# - { path: ^/profile, roles: ROLE_USER }
|
||||||
|
|
||||||
when@test:
|
when@test:
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Expose your documentation as JSON swagger compliant
|
||||||
|
app.swagger:
|
||||||
|
path: /api/doc.json
|
||||||
|
methods: GET
|
||||||
|
defaults: { _controller: nelmio_api_doc.controller.swagger }
|
||||||
|
|
||||||
|
app.swagger_ui:
|
||||||
|
path: /api/swagger
|
||||||
|
methods: GET
|
||||||
|
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
|
||||||
@@ -20,5 +20,9 @@ services:
|
|||||||
- '../src/Entity/'
|
- '../src/Entity/'
|
||||||
- '../src/Kernel.php'
|
- '../src/Kernel.php'
|
||||||
|
|
||||||
|
App\Service\FileUploaderService:
|
||||||
|
arguments:
|
||||||
|
$targetDirectory: 'images/'
|
||||||
|
|
||||||
# add more service definitions when explicit configuration is needed
|
# add more service definitions when explicit configuration is needed
|
||||||
# please note that last definitions always *replace* previous ones
|
# please note that last definitions always *replace* previous ones
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+89
-4
@@ -15,7 +15,7 @@ SomniaRooms back-end and front-end can run on the same machine, but some config
|
|||||||
### Deploy back-end and front-end on different servers (different ip address).
|
### Deploy back-end and front-end on different servers (different ip address).
|
||||||
If your servers have different IP addresses everything is a little bit easier. You can set-up subdomains for each one.
|
If your servers have different IP addresses everything is a little bit easier. You can set-up subdomains for each one.
|
||||||
|
|
||||||
Use the following docker compose files for back-end and front-end.
|
Use the following docker compose files to deploy back-end and front-end on different servers.
|
||||||
|
|
||||||
Back-end:
|
Back-end:
|
||||||
```yml
|
```yml
|
||||||
@@ -25,7 +25,8 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
SERVER_NAME: https://api.somnia.dev # <-- Your hostname here!
|
SERVER_NAME: https://api.somnia.dev # <-- Your hostname here!
|
||||||
DATABASE_URL: postgresql://somnia:ChangeMe!@database/somniarooms?serverVersion=16&ch> MERCURE_PUBLISHER_JWT_KEY: ChangeThisMercureHubJWTSecretKey!
|
DATABASE_URL: postgresql://somnia:ChangeMe!@database/somniarooms?serverVersion=16&charset=utf8
|
||||||
|
MERCURE_PUBLISHER_JWT_KEY: ChangeThisMercureHubJWTSecretKey!
|
||||||
MERCURE_SUBSCRIBER_JWT_KEY: ChangeThisMercureHubJWTSecretKey!
|
MERCURE_SUBSCRIBER_JWT_KEY: ChangeThisMercureHubJWTSecretKey!
|
||||||
APP_SECRET: ChangeMySecret
|
APP_SECRET: ChangeMySecret
|
||||||
FRANKENPHP_CONFIG: "" # <-- Dont touch this line unless you know what are doing.
|
FRANKENPHP_CONFIG: "" # <-- Dont touch this line unless you know what are doing.
|
||||||
@@ -95,7 +96,7 @@ services:
|
|||||||
|
|
||||||
|
|
||||||
### Deploy on the same server.
|
### Deploy on the same server.
|
||||||
Right now, it's quite difficult to set back-end app on a port different from 80/443. Back-end uses Caddy as webserver and automatically try to get SSL certs from let's encrypt.
|
Right now, it's quite difficult to set back-end app on a port different from 80/443. Back-end uses Caddy as webserver and automatically try to get SSL certs from let's encrypt. If back-end port is changed, back-end server address should be http to avoid failed TLS challenges.
|
||||||
|
|
||||||
My go-to option will be using some reverse-proxy to redirect requests to back or front by domain name.
|
My go-to option will be using some reverse-proxy to redirect requests to back or front by domain name.
|
||||||
|
|
||||||
@@ -140,6 +141,8 @@ services:
|
|||||||
MERCURE_SUBSCRIBER_JWT_KEY: ChangeThisMercureHubJWTSecretKey!
|
MERCURE_SUBSCRIBER_JWT_KEY: ChangeThisMercureHubJWTSecretKey!
|
||||||
APP_SECRET: ChangeMySecret
|
APP_SECRET: ChangeMySecret
|
||||||
FRANKENPHP_CONFIG: "" # <-- Dont touch this line unless you know what are doing.
|
FRANKENPHP_CONFIG: "" # <-- Dont touch this line unless you know what are doing.
|
||||||
|
TRUSTED_HOSTS: api.somnia.dev
|
||||||
|
TRUSTED_PROXIES: reverse-proxy
|
||||||
volumes:
|
volumes:
|
||||||
- caddy_data:/data
|
- caddy_data:/data
|
||||||
- caddy_config:/config
|
- caddy_config:/config
|
||||||
@@ -152,6 +155,7 @@ services:
|
|||||||
- "traefik.http.routers.somniarooms-back.entrypoints=websecure"
|
- "traefik.http.routers.somniarooms-back.entrypoints=websecure"
|
||||||
- "traefik.http.routers.somniarooms-back.tls=true"
|
- "traefik.http.routers.somniarooms-back.tls=true"
|
||||||
- "traefik.http.routers.somniarooms-back.tls.certresolver=lets-encrypt"
|
- "traefik.http.routers.somniarooms-back.tls.certresolver=lets-encrypt"
|
||||||
|
- "traefik.http.services.somniarooms-back.loadbalancer.server.port=80"
|
||||||
|
|
||||||
somniarooms-front:
|
somniarooms-front:
|
||||||
image: gitea.uberelectronnetwork.cc/somnia/somniaroomsapp:devbuild
|
image: gitea.uberelectronnetwork.cc/somnia/somniaroomsapp:devbuild
|
||||||
@@ -164,7 +168,10 @@ services:
|
|||||||
- somniarooms-back
|
- somniarooms-back
|
||||||
labels:
|
labels:
|
||||||
- "traefik.http.routers.somniarooms-front.rule=Host(`app.somnia.dev`)" # <-- Your front-end hostname here!
|
- "traefik.http.routers.somniarooms-front.rule=Host(`app.somnia.dev`)" # <-- Your front-end hostname here!
|
||||||
|
- "traefik.http.routers.somniarooms-front.entrypoints=websecure"
|
||||||
|
- "traefik.http.routers.somniarooms-front.tls=true"
|
||||||
|
- "traefik.http.routers.somniarooms-front.tls.certresolver=lets-encrypt"
|
||||||
|
- "traefik.http.services.somniarooms-front.loadbalancer.server.port=80"
|
||||||
|
|
||||||
database:
|
database:
|
||||||
image: postgres:16-alpine
|
image: postgres:16-alpine
|
||||||
@@ -189,6 +196,84 @@ volumes:
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you dont care about SSL, you can set it up using HTTP only.
|
||||||
|
You may need to use different ports for back-end and front-end.
|
||||||
|
|
||||||
|
This setup uses the following config:
|
||||||
|
- back-end -> port 8001.
|
||||||
|
- front-end -> port 80.
|
||||||
|
|
||||||
|
```yml
|
||||||
|
services:
|
||||||
|
somniarooms-back:
|
||||||
|
image: gitea.uberelectronnetwork.cc/somnia/somniarooms:devbuild
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
# Server name should be "HTTP" to disable auto certs.
|
||||||
|
# Set listening port as well if different from 80/443.
|
||||||
|
# If a server name is set, Caddy will only work for that name. You can set all you need comma separated.
|
||||||
|
# You can "wildcard" as well if that's your thing...
|
||||||
|
# SERVER_NAME: :8001
|
||||||
|
SERVER_NAME: http://api.somnia.dev:8001, http://IP:8001
|
||||||
|
DATABASE_URL: postgresql://somnia:ChangeMe!@database/somniarooms?serverVersion=16&charset=utf8
|
||||||
|
MERCURE_PUBLISHER_JWT_KEY: ChangeThisMercureHubJWTSecretKey!
|
||||||
|
MERCURE_SUBSCRIBER_JWT_KEY: ChangeThisMercureHubJWTSecretKey!
|
||||||
|
FRANKENPHP_CONFIG: ""
|
||||||
|
APP_SECRET: ChangeMySecret
|
||||||
|
TRUSTED_HOSTS: api.somnia.dev
|
||||||
|
volumes:
|
||||||
|
- caddy_data:/data
|
||||||
|
- caddy_config:/config
|
||||||
|
ports:
|
||||||
|
# HTTP
|
||||||
|
# Target port must be the same as SERVER_NAME. Caddy will use SERVER_NAME port instead of 80/443 if set.
|
||||||
|
- target: 8001
|
||||||
|
published: 8001
|
||||||
|
depends_on:
|
||||||
|
- database
|
||||||
|
|
||||||
|
somniarooms-front:
|
||||||
|
image: gitea.uberelectronnetwork.cc/somnia/somniaroomsapp:devbuild
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
# You should set your public IP/hostname to back-end.
|
||||||
|
# You may have problems with CORS... Make sure back and front have same domain or allow requests for those domains.
|
||||||
|
SOMNIAROOMS_BACKEND_HOST: http://api.somnia.dev
|
||||||
|
SOMNIAROOMS_BACKEND_PORT: 8001 # <-- Set back-end published port.
|
||||||
|
ports:
|
||||||
|
# HTTP
|
||||||
|
- target: 80
|
||||||
|
published: 80
|
||||||
|
# HTTPS.
|
||||||
|
# Uncomment if HTTPS is available. You should configure certs by yourself here.
|
||||||
|
#- target: 443
|
||||||
|
# published: 443
|
||||||
|
depends_on:
|
||||||
|
- somniarooms-back
|
||||||
|
|
||||||
|
database:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
environment:
|
||||||
|
POSTGRES_DB: somniarooms
|
||||||
|
# You should definitely change the password in production. Remember to change DATABASE_URL as well.
|
||||||
|
POSTGRES_PASSWORD: ChangeMe!
|
||||||
|
POSTGRES_USER: somnia
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "pg_isready"]
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
start_period: 60s
|
||||||
|
volumes:
|
||||||
|
- database_data:/var/lib/postgresql/data:rw
|
||||||
|
# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!
|
||||||
|
# - ./docker/db/data:/var/lib/postgresql/data:rw
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
caddy_data:
|
||||||
|
caddy_config:
|
||||||
|
database_data:
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## What's next?
|
## What's next?
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the importmap for this application.
|
||||||
|
*
|
||||||
|
* - "path" is a path inside the asset mapper system. Use the
|
||||||
|
* "debug:asset-map" command to see the full list of paths.
|
||||||
|
*
|
||||||
|
* - "entrypoint" (JavaScript only) set to true for any module that will
|
||||||
|
* be used as an "entrypoint" (and passed to the importmap() Twig function).
|
||||||
|
*
|
||||||
|
* The "importmap:require" command can be used to add new entries to this file.
|
||||||
|
*/
|
||||||
|
return [
|
||||||
|
'app' => [
|
||||||
|
'path' => './assets/app.js',
|
||||||
|
'entrypoint' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240604185317 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('DROP SEQUENCE config_variable_id_seq CASCADE');
|
||||||
|
$this->addSql('DROP INDEX uniq_718569538a90aba9');
|
||||||
|
$this->addSql('ALTER TABLE config_variable DROP CONSTRAINT config_variable_pkey');
|
||||||
|
$this->addSql('ALTER TABLE config_variable DROP id');
|
||||||
|
$this->addSql('ALTER TABLE config_variable ALTER section SET NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE config_variable ALTER section TYPE VARCHAR(255)');
|
||||||
|
$this->addSql('ALTER TABLE config_variable ADD PRIMARY KEY (key)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('CREATE SEQUENCE config_variable_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('DROP INDEX config_variable_pkey');
|
||||||
|
$this->addSql('ALTER TABLE config_variable ADD id INT NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE config_variable ALTER section DROP NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE config_variable ALTER section TYPE VARCHAR(64)');
|
||||||
|
$this->addSql('CREATE UNIQUE INDEX uniq_718569538a90aba9 ON config_variable (key)');
|
||||||
|
$this->addSql('ALTER TABLE config_variable ADD PRIMARY KEY (id)');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240909114239 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('DROP SEQUENCE room_category_details_id_seq CASCADE');
|
||||||
|
$this->addSql('ALTER TABLE room_category_details DROP CONSTRAINT fk_3735fabb67333dd');
|
||||||
|
$this->addSql('DROP TABLE room_category_details');
|
||||||
|
$this->addSql('ALTER TABLE room_category_photo ADD photo_order INT DEFAULT NULL');
|
||||||
|
$this->addSql('ALTER TABLE room_category_photo DROP kind');
|
||||||
|
$this->addSql('ALTER TABLE room_fare DROP CONSTRAINT FK_35C9B213A7233EF2');
|
||||||
|
$this->addSql('ALTER TABLE room_fare ADD CONSTRAINT FK_35C9B213A7233EF2 FOREIGN KEY (fare_table_id) REFERENCES fare_table (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('CREATE SEQUENCE room_category_details_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE TABLE room_category_details (id INT NOT NULL, room_category_id INT NOT NULL, details_section VARCHAR(255) NOT NULL, detail_value VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE INDEX idx_3735fabb67333dd ON room_category_details (room_category_id)');
|
||||||
|
$this->addSql('ALTER TABLE room_category_details ADD CONSTRAINT fk_3735fabb67333dd FOREIGN KEY (room_category_id) REFERENCES room_category (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('ALTER TABLE room_fare DROP CONSTRAINT fk_35c9b213a7233ef2');
|
||||||
|
$this->addSql('ALTER TABLE room_fare ADD CONSTRAINT fk_35c9b213a7233ef2 FOREIGN KEY (fare_table_id) REFERENCES fare_table (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('ALTER TABLE room_category_photo ADD kind VARCHAR(30) NOT NULL');
|
||||||
|
$this->addSql('ALTER TABLE room_category_photo DROP photo_order');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240909131104 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SEQUENCE bed_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||||
|
$this->addSql('CREATE TABLE bed_type (id INT NOT NULL, name VARCHAR(255) DEFAULT NULL, icon_url VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))');
|
||||||
|
$this->addSql('CREATE TABLE room_category_bed_type (room_category_id INT NOT NULL, bed_type_id INT NOT NULL, amount INT NOT NULL, PRIMARY KEY(room_category_id, bed_type_id))');
|
||||||
|
$this->addSql('CREATE INDEX IDX_FB45954567333DD ON room_category_bed_type (room_category_id)');
|
||||||
|
$this->addSql('CREATE INDEX IDX_FB4595458158330E ON room_category_bed_type (bed_type_id)');
|
||||||
|
$this->addSql('ALTER TABLE room_category_bed_type ADD CONSTRAINT FK_FB45954567333DD FOREIGN KEY (room_category_id) REFERENCES room_category (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
$this->addSql('ALTER TABLE room_category_bed_type ADD CONSTRAINT FK_FB4595458158330E FOREIGN KEY (bed_type_id) REFERENCES bed_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('DROP SEQUENCE bed_type_id_seq CASCADE');
|
||||||
|
$this->addSql('ALTER TABLE room_category_bed_type DROP CONSTRAINT FK_FB45954567333DD');
|
||||||
|
$this->addSql('ALTER TABLE room_category_bed_type DROP CONSTRAINT FK_FB4595458158330E');
|
||||||
|
$this->addSql('DROP TABLE bed_type');
|
||||||
|
$this->addSql('DROP TABLE room_category_bed_type');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240910160534 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE room_category DROP bed_type');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('ALTER TABLE room_category ADD bed_type VARCHAR(64) DEFAULT NULL');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20240916181831 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('ALTER TABLE room_category ADD order_home_page SMALLINT DEFAULT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql('CREATE SCHEMA public');
|
||||||
|
$this->addSql('ALTER TABLE room_category DROP order_home_page');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
images/
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use App\DTO\ApiErrorMessage;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
|
||||||
|
class ApiErrorException extends HttpException
|
||||||
|
{
|
||||||
|
|
||||||
|
private ApiErrorMessage $apiErrorMsg;
|
||||||
|
|
||||||
|
public function __construct(ApiErrorMessage $apiErrorMsg, $detailsData = null, \Exception $previous = null, array $headers = array(), $code = 0)
|
||||||
|
{
|
||||||
|
$this->apiErrorMsg = $apiErrorMsg;
|
||||||
|
|
||||||
|
if (isset($detailsData)) {
|
||||||
|
$this->apiErrorMsg->setDetails($detailsData);
|
||||||
|
}
|
||||||
|
|
||||||
|
$statusCode = $apiErrorMsg->getStatusCode();
|
||||||
|
$message = $apiErrorMsg->getTitle();
|
||||||
|
|
||||||
|
parent::__construct($statusCode, $message, $previous, $headers, $code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getApiErrorMsg(): ApiErrorMessage
|
||||||
|
{
|
||||||
|
return $this->apiErrorMsg;
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-8
@@ -2,23 +2,21 @@
|
|||||||
|
|
||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
use App\Entity\RoomCategoryDetails;
|
use App\Entity\BedType;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Field\UrlField;
|
||||||
|
|
||||||
class RoomCategoryDetailsCrudController extends AbstractCrudController
|
class BedTypeCrudController extends AbstractCrudController
|
||||||
{
|
{
|
||||||
public static function getEntityFqcn(): string
|
public static function getEntityFqcn(): string
|
||||||
{
|
{
|
||||||
return RoomCategoryDetails::class;
|
return BedType::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function configureFields(string $pageName): iterable
|
public function configureFields(string $pageName): iterable
|
||||||
{
|
{
|
||||||
return [
|
yield TextField::new('name');
|
||||||
TextField::new('detailsSection'),
|
yield UrlField::new('iconUrl');
|
||||||
TextField::new('detailValue'),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ class BookingCrudController extends AbstractCrudController
|
|||||||
public function configureFields(string $pageName): iterable
|
public function configureFields(string $pageName): iterable
|
||||||
{
|
{
|
||||||
$fieldRefNumber = TextField::new ('refNumber');
|
$fieldRefNumber = TextField::new ('refNumber');
|
||||||
$fieldBookingTime = DateTimeField::new ('BookingTime');
|
$fieldBookingTime = DateTimeField::new('bookingTime');
|
||||||
if ($pageName == Crud::PAGE_EDIT) {
|
if ($pageName == Crud::PAGE_EDIT) {
|
||||||
$fieldRefNumber->setDisabled(true);
|
$fieldRefNumber->setDisabled(true);
|
||||||
$fieldBookingTime->setDisabled(true);
|
$fieldBookingTime->setDisabled(true);
|
||||||
@@ -33,8 +33,8 @@ class BookingCrudController extends AbstractCrudController
|
|||||||
yield $fieldRefNumber;
|
yield $fieldRefNumber;
|
||||||
yield $fieldBookingTime;
|
yield $fieldBookingTime;
|
||||||
|
|
||||||
yield DateField::new ('ArrivalDate');
|
yield DateField::new('arrivalDate');
|
||||||
yield DateField::new ('DepartureDate');
|
yield DateField::new('departureDate');
|
||||||
|
|
||||||
yield AssociationField::new ('bookingCustomer')->renderAsEmbeddedForm(BookingCustomerCrudController::class);
|
yield AssociationField::new ('bookingCustomer')->renderAsEmbeddedForm(BookingCustomerCrudController::class);
|
||||||
yield CollectionField::new ('bookingRooms')->useEntryCrudForm();
|
yield CollectionField::new ('bookingRooms')->useEntryCrudForm();
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ class BookingCustomerCrudController extends AbstractCrudController
|
|||||||
|
|
||||||
public function configureFields(string $pageName): iterable
|
public function configureFields(string $pageName): iterable
|
||||||
{
|
{
|
||||||
yield TextField::new('Name');
|
yield TextField::new('name');
|
||||||
yield TextField::new('Surname');
|
yield TextField::new('surname');
|
||||||
yield TextField::new('Email');
|
yield TextField::new('email');
|
||||||
yield TextField::new('PhoneNumber');
|
yield TextField::new('phoneNumber');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ class BookingRoomCrudController extends AbstractCrudController
|
|||||||
|
|
||||||
public function configureFields(string $pageName): iterable
|
public function configureFields(string $pageName): iterable
|
||||||
{
|
{
|
||||||
yield AssociationField::new ('RoomCategory')->setCrudController(RoomCategoryCrudController::class);
|
yield AssociationField::new('roomCategory')->setCrudController(RoomCategoryCrudController::class);
|
||||||
yield NumberField::new ('GuestNumber');
|
yield NumberField::new('guestNumber');
|
||||||
yield MoneyField::new ('RoomPrice')->setCurrency("EUR");
|
yield MoneyField::new('roomPrice')->setCurrency("EUR");
|
||||||
yield NumberField::new ('Amount');
|
yield NumberField::new('amount');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,11 @@
|
|||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
use App\Entity\ConfigVariable;
|
use App\Entity\ConfigVariable;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
use App\Enum\ConfigSectionType;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||||
|
|
||||||
class ConfigVariableCrudController extends AbstractCrudController
|
class ConfigVariableCrudController extends AbstractCrudController
|
||||||
{
|
{
|
||||||
@@ -14,11 +16,15 @@ class ConfigVariableCrudController extends AbstractCrudController
|
|||||||
return ConfigVariable::class;
|
return ConfigVariable::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function configureCrud(Crud $crud): Crud
|
||||||
|
{
|
||||||
|
return $crud;
|
||||||
|
}
|
||||||
|
|
||||||
public function configureFields(string $pageName): iterable
|
public function configureFields(string $pageName): iterable
|
||||||
{
|
{
|
||||||
yield TextField::new('section');
|
yield ChoiceField::new ('section')->setChoices(ConfigSectionType::cases());
|
||||||
yield TextField::new('key');
|
yield TextField::new ('key');
|
||||||
yield TextField::new('value');
|
yield TextField::new ('value');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,119 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Service\FileUploaderService;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\Asset\PathPackage;
|
||||||
|
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||||
|
use Symfony\Component\Validator\Constraints\File;
|
||||||
|
|
||||||
|
#[IsGranted("ROLE_ADMIN")]
|
||||||
|
class PhotoManagerAdminController extends AbstractController
|
||||||
|
{
|
||||||
|
|
||||||
|
private AdminUrlGenerator $adminUrlGenerator;
|
||||||
|
private FileUploaderService $fileUploader;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
AdminUrlGenerator $adminUrlGenerator,
|
||||||
|
FileUploaderService $fu
|
||||||
|
) {
|
||||||
|
$this->adminUrlGenerator = $adminUrlGenerator;
|
||||||
|
$this->fileUploader = $fu;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[Route('/admin/photos', name: 'admin_photos')]
|
||||||
|
public function index(): Response
|
||||||
|
{
|
||||||
|
$fileData = [];
|
||||||
|
|
||||||
|
$dir = $this->fileUploader->getTargetDirectory();
|
||||||
|
$pathPackage = new PathPackage($dir, new EmptyVersionStrategy());
|
||||||
|
|
||||||
|
foreach (glob($dir . '*.*') as $file) {
|
||||||
|
$filename = basename($file);
|
||||||
|
$fileData[] = [
|
||||||
|
"filename" => $filename,
|
||||||
|
"url" => $pathPackage->getUrl($filename),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
//return new JsonResponse(["dir" => $dir, "response" => $fileData]);
|
||||||
|
|
||||||
|
return $this->render('admin/photo_manager/index.html.twig', [
|
||||||
|
'photoList' => $fileData,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/admin/photos/upload', name: 'admin_photos_upload')]
|
||||||
|
public function uploadPhoto(
|
||||||
|
Request $request
|
||||||
|
): Response {
|
||||||
|
|
||||||
|
$form = $this->createFormBuilder()
|
||||||
|
->add('file', FileType::class, [
|
||||||
|
'mapped' => false,
|
||||||
|
'required' => false,
|
||||||
|
'constraints' => [
|
||||||
|
new File([
|
||||||
|
'maxSize' => '2048k',
|
||||||
|
'mimeTypes' => [
|
||||||
|
'image/jpeg',
|
||||||
|
'image/png',
|
||||||
|
'image/svg+xml',
|
||||||
|
'image/webp',
|
||||||
|
],
|
||||||
|
'mimeTypesMessage' => 'Please upload a valid image!',
|
||||||
|
])
|
||||||
|
],
|
||||||
|
])
|
||||||
|
->add('submit', SubmitType::class)
|
||||||
|
->getForm();
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
/** @var UploadedFile $uploadedPhoto */
|
||||||
|
$uploadedPhoto = $form->get('file')->getData();
|
||||||
|
|
||||||
|
if ($uploadedPhoto) {
|
||||||
|
$filename = $this->fileUploader->upload($uploadedPhoto);
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $this->adminUrlGenerator->setRoute('admin_photos')->generateUrl();
|
||||||
|
return $this->redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('admin/adminEdit.html.twig', [
|
||||||
|
'form' => $form,
|
||||||
|
'ElementName' => "Photo",
|
||||||
|
'ElementType' => "New Photo",
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/admin/photos/remove/{filename}', name: 'admin_photos_remove')]
|
||||||
|
public function remove(string $filename): Response
|
||||||
|
{
|
||||||
|
$filePath = $this->fileUploader->getTargetDirectory() . $filename;
|
||||||
|
$deleted = $this->fileUploader->deleteFile($filePath);
|
||||||
|
|
||||||
|
if (!$deleted) {
|
||||||
|
throw new HttpException("404", "File can't be deleted");
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $this->adminUrlGenerator->setRoute('admin_photos')->generateUrl();
|
||||||
|
return $this->redirect($url);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,6 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|||||||
#[IsGranted("ROLE_ADMIN")]
|
#[IsGranted("ROLE_ADMIN")]
|
||||||
class RoomAvailabilityAdminController extends AbstractController
|
class RoomAvailabilityAdminController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
private $adminUrlGenerator;
|
private $adminUrlGenerator;
|
||||||
private EntityManagerInterface $entityManager;
|
private EntityManagerInterface $entityManager;
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ class RoomAvailabilityAdminController extends AbstractController
|
|||||||
//TODOME: Aquí deberíamos llevar a una página de error o algo.
|
//TODOME: Aquí deberíamos llevar a una página de error o algo.
|
||||||
|
|
||||||
$url = $this->adminUrlGenerator->setRoute('admin_roomAvailability_category', [
|
$url = $this->adminUrlGenerator->setRoute('admin_roomAvailability_category', [
|
||||||
'categoryId' => $item->getId(),
|
'categoryId' => $categoryId,
|
||||||
])->generateUrl();
|
])->generateUrl();
|
||||||
return $this->redirect($url);
|
return $this->redirect($url);
|
||||||
}
|
}
|
||||||
@@ -129,19 +128,4 @@ class RoomAvailabilityAdminController extends AbstractController
|
|||||||
'categoryId' => $categoryId,
|
'categoryId' => $categoryId,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/admin/roomAvailabilityTEST/', name: 'admin_roomAvailability_test')]
|
|
||||||
public function availabilityTest(EntityManagerInterface $entityManager): Response
|
|
||||||
{
|
|
||||||
$avl = new RoomAvailability();
|
|
||||||
|
|
||||||
$avl->setDay(new \DateTime("2024-04-24"));
|
|
||||||
$avl->setRoomCategory($entityManager->find(RoomCategory::class, 4));
|
|
||||||
$avl->setNumAvailable(2);
|
|
||||||
|
|
||||||
$entityManager->persist($avl);
|
|
||||||
$entityManager->flush();
|
|
||||||
|
|
||||||
return $this->json($avl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Entity\RoomCategory;
|
||||||
|
use App\Entity\RoomCategoryBedType;
|
||||||
|
use App\Repository\RoomCategoryRepository;
|
||||||
|
use App\Repository\RoomCategoryBedTypeRepository;
|
||||||
|
use App\Form\RoomCategoryBedTypeFormType;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||||
|
|
||||||
|
#[IsGranted("ROLE_ADMIN")]
|
||||||
|
class RoomCategoryBedTypeAdminController extends AbstractController
|
||||||
|
{
|
||||||
|
private $adminUrlGenerator;
|
||||||
|
private EntityManagerInterface $entityManager;
|
||||||
|
|
||||||
|
public function __construct(AdminUrlGenerator $adminUrlGenerator, EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
$this->adminUrlGenerator = $adminUrlGenerator;
|
||||||
|
$this->entityManager = $em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/admin/roomCategoryBedType', name: 'admin_roomCategoryBedType')]
|
||||||
|
public function index(RoomCategoryRepository $catRepo): Response
|
||||||
|
{
|
||||||
|
$categoryList = $catRepo->findAll();
|
||||||
|
|
||||||
|
return $this->render('admin/room_category_bed_type_admin/index.html.twig', [
|
||||||
|
'roomCategoryList' => $categoryList,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// List BedTypes from category.
|
||||||
|
#[Route('/admin/roomCategoryBedType/{categoryId}', name: 'admin_roomCategoryBedType_category')]
|
||||||
|
public function categoryBedTypes(RoomCategoryRepository $catRepo, RoomCategoryBedTypeRepository $repo, string $categoryId): Response
|
||||||
|
{
|
||||||
|
$category = $catRepo->find($categoryId);
|
||||||
|
$bedTypeList = $repo->findByRoomCategory($categoryId);
|
||||||
|
|
||||||
|
return $this->render('admin/room_category_bed_type_admin/categoryBedTypes.html.twig', [
|
||||||
|
'categoryData' => $category,
|
||||||
|
'bedTypeList' => $bedTypeList,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a RoomCategory BedType.
|
||||||
|
#[Route('/admin/roomCategoryBedType/{categoryId}/new', name: 'admin_roomCategoryBedType_category_create')]
|
||||||
|
public function createCategoryBedType(Request $request, RoomCategoryBedTypeRepository $repo, string $categoryId): Response
|
||||||
|
{
|
||||||
|
$roomCatBedType = new RoomCategoryBedType();
|
||||||
|
$roomCategoryItem = $this->entityManager->find(RoomCategory::class, $categoryId);
|
||||||
|
$roomCatBedType->setRoomCategory($roomCategoryItem);
|
||||||
|
|
||||||
|
$form = $this->createForm(RoomCategoryBedTypeFormType::class, $roomCatBedType, [
|
||||||
|
'selectRoomCategory' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
// $form->getData() holds the submitted values
|
||||||
|
// but, the original `$availabilityItem` variable has also been updated
|
||||||
|
|
||||||
|
$this->entityManager->persist($roomCatBedType);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
$url = $this->adminUrlGenerator->setRoute('admin_roomCategoryBedType_category', [
|
||||||
|
'categoryId' => $roomCatBedType->getRoomCategory()->getId(),
|
||||||
|
])->generateUrl();
|
||||||
|
|
||||||
|
return $this->redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('admin/adminEdit.html.twig', [
|
||||||
|
'form' => $form,
|
||||||
|
'ElementType' => "Room Categoy Bed Type",
|
||||||
|
'ElementName' => "Room Categoy - " . $roomCategoryItem
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit a RoomCategory BedType.
|
||||||
|
#[Route('/admin/roomCategoryBedType/{categoryId}/{bedTypeId}/edit', name: 'admin_roomCategoryBedType_category_update')]
|
||||||
|
public function updateCategoryBedType(Request $request, RoomCategoryBedTypeRepository $repo, string $categoryId, string $bedTypeId): Response
|
||||||
|
{
|
||||||
|
$categoryBedTypeItem = $repo->find(["bedType" => $bedTypeId, "roomCategory" => $categoryId]);
|
||||||
|
|
||||||
|
if ($categoryBedTypeItem == null) {
|
||||||
|
//TODOME: Aquí deberíamos llevar a una página de error o algo.
|
||||||
|
|
||||||
|
$url = $this->adminUrlGenerator->setRoute('admin_roomCategoryBedType_category', [
|
||||||
|
'categoryId' => $categoryId,
|
||||||
|
])->generateUrl();
|
||||||
|
return $this->redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = $this->createForm(RoomCategoryBedTypeFormType::class, $categoryBedTypeItem, [
|
||||||
|
'selectRoomCategory' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
// $form->getData() holds the submitted values
|
||||||
|
// but, the original `$categoryBedTypeItem` variable has also been updated
|
||||||
|
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
$url = $this->adminUrlGenerator->setRoute('admin_roomCategoryBedType_category', [
|
||||||
|
'categoryId' => $categoryId,
|
||||||
|
])->generateUrl();
|
||||||
|
|
||||||
|
return $this->redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('admin/adminEdit.html.twig', [
|
||||||
|
'form' => $form,
|
||||||
|
'ElementType' => "Room Categoy Bed Type",
|
||||||
|
'ElementName' => "Room Categoy - " . $categoryBedTypeItem->getRoomCategory()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove a RoomCategoryBedType.
|
||||||
|
#[Route('/admin/roomCategoryBedType/{categoryId}/{bedTypeId}/remove', name: 'admin_roomCategoryBedType_category_remove')]
|
||||||
|
public function removeCategoryBedType(RoomCategoryBedTypeRepository $repo, string $categoryId, string $bedTypeId) : Response {
|
||||||
|
$categoryBedTypeItem = $repo->find(["bedType" => $bedTypeId, "roomCategory" => $categoryId]);
|
||||||
|
if(!$categoryBedTypeItem) {
|
||||||
|
throw $this->createNotFoundException('Element not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entityManager->remove($categoryBedTypeItem);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
|
||||||
|
$url = $this->adminUrlGenerator->setRoute('admin_roomCategoryBedType_category', [
|
||||||
|
'categoryId' => $categoryId,
|
||||||
|
])->generateUrl();
|
||||||
|
return $this->redirect($url);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Entity\RoomCategoryBedType;
|
||||||
|
use App\Form\RoomCategoryBedTypeForm;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
|
||||||
|
use EasyCorp\Bundle\EasyAdminBundle\Config\Page;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
|
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
|
||||||
@@ -27,14 +30,10 @@ class RoomCategoryCrudController extends AbstractCrudController
|
|||||||
|
|
||||||
public function configureFields(string $pageName): iterable
|
public function configureFields(string $pageName): iterable
|
||||||
{
|
{
|
||||||
return [
|
yield TextField::new('name');
|
||||||
//IdField::new('id'),
|
yield TextField::new('description');
|
||||||
TextField::new('name'),
|
yield IntegerField::new('maxGuestNum');
|
||||||
TextField::new('description'),
|
yield IntegerField::new('orderHomePage');
|
||||||
TextField::new('bedType'),
|
yield CollectionField::new('roomCategoryPhotos')->useEntryCrudForm();
|
||||||
IntegerField::new('maxGuestNum'),
|
|
||||||
CollectionField::new('roomCategoryDetails')->useEntryCrudForm(),
|
|
||||||
CollectionField::new('roomCategoryPhotos')->useEntryCrudForm()
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace App\Controller\Admin;
|
|||||||
use App\Entity\RoomCategoryPhoto;
|
use App\Entity\RoomCategoryPhoto;
|
||||||
use App\Entity\RoomCategoryPhotoKinds;
|
use App\Entity\RoomCategoryPhotoKinds;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
|
||||||
use EasyCorp\Bundle\EasyAdminBundle\Field\{TextField, ChoiceField};
|
use EasyCorp\Bundle\EasyAdminBundle\Field\{TextField, IntegerField};
|
||||||
|
|
||||||
class RoomCategoryPhotoCrudController extends AbstractCrudController
|
class RoomCategoryPhotoCrudController extends AbstractCrudController
|
||||||
{
|
{
|
||||||
@@ -18,7 +18,7 @@ class RoomCategoryPhotoCrudController extends AbstractCrudController
|
|||||||
{
|
{
|
||||||
yield TextField::new('path');
|
yield TextField::new('path');
|
||||||
yield TextField::new('altText');
|
yield TextField::new('altText');
|
||||||
yield ChoiceField::new('kind')->setChoices(['Main' => 'main', 'Bathroom' => 'bathroom', 'Other' => 'other']);
|
yield IntegerField::new('photoOrder');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,8 @@ class RoomFareCrudController extends AbstractCrudController
|
|||||||
|
|
||||||
public function configureFields(string $pageName): iterable
|
public function configureFields(string $pageName): iterable
|
||||||
{
|
{
|
||||||
$fieldFareTable = AssociationField::new ('fareTable')->setRequired(true);
|
$fieldFareTable = AssociationField::new('fareTable')->setRequired(true)
|
||||||
|
->formatValue(fn ($value) => $value->getComment() . " (" . $value->getRoomCategory() . ")");
|
||||||
if ($pageName == Crud::PAGE_EDIT) {
|
if ($pageName == Crud::PAGE_EDIT) {
|
||||||
$fieldFareTable->setDisabled(true);
|
$fieldFareTable->setDisabled(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Controller\Admin;
|
namespace App\Controller\Admin;
|
||||||
|
|
||||||
|
use App\Entity\BedType;
|
||||||
use App\Entity\Booking;
|
use App\Entity\Booking;
|
||||||
use App\Entity\ConfigVariable;
|
use App\Entity\ConfigVariable;
|
||||||
use App\Entity\FareTable;
|
use App\Entity\FareTable;
|
||||||
@@ -40,7 +41,14 @@ class SomniaDashboardController extends AbstractDashboardController
|
|||||||
yield MenuItem::linkToRoute('Room Availability', 'fas fa-calendar-check', 'admin_roomAvailability');
|
yield MenuItem::linkToRoute('Room Availability', 'fas fa-calendar-check', 'admin_roomAvailability');
|
||||||
yield MenuItem::linkToCrud('Fare Tables', 'fas fa-table', FareTable::class);
|
yield MenuItem::linkToCrud('Fare Tables', 'fas fa-table', FareTable::class);
|
||||||
yield MenuItem::linkToCrud('Room Fares', 'fas fa-tag', RoomFare::class);
|
yield MenuItem::linkToCrud('Room Fares', 'fas fa-tag', RoomFare::class);
|
||||||
|
|
||||||
|
yield MenuItem::Section('Category Configuration');
|
||||||
|
yield MenuItem::linkToCrud('Bed Types', 'fas fa-bed', BedType::class);
|
||||||
|
yield MenuItem::linkToRoute('Bed Type - category', 'fas fa-bed', 'admin_roomCategoryBedType');
|
||||||
|
|
||||||
|
yield MenuItem::Section('Resources');
|
||||||
|
yield MenuItem::linkToRoute('Photos', 'fas fa-image', 'admin_photos');
|
||||||
|
|
||||||
yield MenuItem::Section('App Management');
|
yield MenuItem::Section('App Management');
|
||||||
yield MenuItem::linkToCrud('Config Vars', 'fas fa-gear', ConfigVariable::class);
|
yield MenuItem::linkToCrud('Config Vars', 'fas fa-gear', ConfigVariable::class);
|
||||||
yield MenuItem::linkToCrud('Users', 'fas fa-user', User::class)
|
yield MenuItem::linkToCrud('Users', 'fas fa-user', User::class)
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\DTO\AppSetupConfig;
|
||||||
|
use App\DTO\ExampleDataConfig;
|
||||||
|
use App\Entity\ConfigVariable;
|
||||||
|
use App\Form\AppSetupFormType;
|
||||||
|
use App\Form\ExampleDataFormType;
|
||||||
|
use App\Repository\RoomCategoryRepository;
|
||||||
|
use App\Service\AppSetupService;
|
||||||
|
use App\Service\ExampleDataService;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Monolog\Logger;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
|
class AppSetupController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route(path: '/setup', name: 'app_setup_setup')]
|
||||||
|
public function addAdmin(
|
||||||
|
LoggerInterface $logger,
|
||||||
|
AppSetupService $setupService,
|
||||||
|
Request $request,
|
||||||
|
EntityManagerInterface $entityManager
|
||||||
|
): Response {
|
||||||
|
|
||||||
|
$configRepo = $entityManager->getRepository(ConfigVariable::class);
|
||||||
|
$setupStatus = $configRepo->findBy(["key" => "SETUP_STATUS"]);
|
||||||
|
|
||||||
|
if ($setupStatus != null && $setupStatus[0] != null && $setupStatus[0]->getValue() == 1) {
|
||||||
|
$logger->warning("SomniaRooms was already setup");
|
||||||
|
|
||||||
|
return $this->GoToResultPage(
|
||||||
|
isError: false,
|
||||||
|
message: "SomniaRooms already setup.",
|
||||||
|
linkRoute: "admin",
|
||||||
|
linkLabel: "Go to admin panel"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = new AppSetupConfig();
|
||||||
|
$form = $this->createForm(AppSetupFormType::class, $config);
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
|
||||||
|
$rs = $setupService->InitialSetup($config);
|
||||||
|
|
||||||
|
if (!$rs) {
|
||||||
|
return $this->GoToResultPage(
|
||||||
|
isError: false,
|
||||||
|
message: "An error occurred during setup proccess, try again."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($config->getGenExampleData()) {
|
||||||
|
return $this->redirectToRoute("app_setup_gendata");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->GoToResultPage(
|
||||||
|
isError: false,
|
||||||
|
message: "SomniaRooms is setup! Go to admin panel to start!",
|
||||||
|
linkRoute: "admin",
|
||||||
|
linkLabel: "Go to admin panel"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('app_setup/setup.html.twig', [
|
||||||
|
'form' => $form,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[Route('/debug/exampleData', name: 'app_setup_gendata')]
|
||||||
|
public function generateData(
|
||||||
|
Request $request,
|
||||||
|
ExampleDataService $dataService,
|
||||||
|
RoomCategoryRepository $roomCategoryRepository
|
||||||
|
): Response {
|
||||||
|
|
||||||
|
$config = new ExampleDataConfig();
|
||||||
|
$form = $this->createForm(ExampleDataFormType::class, $config);
|
||||||
|
$isFormInvalid = $form->isSubmitted() && !$form->isValid();
|
||||||
|
|
||||||
|
//Check for RoomCategories on db.
|
||||||
|
$roomCategoryCount = $roomCategoryRepository->count();
|
||||||
|
$hasRoomCategories = $roomCategoryCount > 0;
|
||||||
|
|
||||||
|
$form->handleRequest($request);
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
|
||||||
|
$rs = $dataService->AddExampleData($config);
|
||||||
|
$isOk = $rs == "OK";
|
||||||
|
$msg = $isOk ? "Example data generated! Go to admin panel to start!" : $rs;
|
||||||
|
|
||||||
|
return $this->GoToResultPage(
|
||||||
|
isError: !$isOk,
|
||||||
|
message: $msg,
|
||||||
|
linkRoute: $isOk ? "admin" : "",
|
||||||
|
linkLabel: $isOk ? "Go to admin panel" : ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('app_setup/exampleData.html.twig', [
|
||||||
|
'form' => $form,
|
||||||
|
'isFormInvalid' => $isFormInvalid,
|
||||||
|
'hasRoomCategories' => $hasRoomCategories
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function GoToResultPage(bool $isError, string $message, string $linkRoute = null, string $linkLabel = null): Response
|
||||||
|
{
|
||||||
|
return $this->render('app_setup/result.html.twig', [
|
||||||
|
'isError' => $isError,
|
||||||
|
'message' => $message,
|
||||||
|
'linkLabel' => $linkLabel,
|
||||||
|
'linkRoute' => $linkRoute
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,122 +2,152 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\ApiErrorException;
|
||||||
|
use App\DTO\ApiErrorMessage;
|
||||||
use App\Entity\Booking;
|
use App\Entity\Booking;
|
||||||
use App\Entity\BookingCustomer;
|
|
||||||
use App\Entity\BookingRoom;
|
use App\Entity\BookingRoom;
|
||||||
use App\Repository\BookingRepository;
|
use App\Repository\BookingRepository;
|
||||||
use App\Repository\RoomCategoryRepository;
|
use App\Repository\RoomCategoryRepository;
|
||||||
use App\Repository\RoomAvailabilityRepository;
|
use App\Repository\RoomAvailabilityRepository;
|
||||||
|
use App\Request\BookingCreateRequest;
|
||||||
|
use App\Request\BookingDetailsRequest;
|
||||||
|
use App\Response\BookingCreateResponse;
|
||||||
use App\Service\PricesService;
|
use App\Service\PricesService;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use OpenApi\Attributes as OA;
|
||||||
|
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
class BookingController extends AbstractController
|
class BookingController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/api/booking/details', name: 'app_booking_details')]
|
/**
|
||||||
public function getBookingDetails(Request $request, BookingRepository $repoBooking): JsonResponse
|
* Get booking details
|
||||||
{
|
*/
|
||||||
$payload = $request->toArray();
|
#[Route('/api/booking/details', name: 'app_booking_details', methods: ["POST"], format: "json")]
|
||||||
if (\is_null($payload)) {
|
#[OA\Tag(name: "Booking")]
|
||||||
throw new \Exception('Invalid Payload', 400);
|
#[OA\Response(
|
||||||
|
response: 200,
|
||||||
|
description: 'Returns booking details',
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
ref: new Model(type: Booking::class),
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
#[OA\RequestBody(
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
ref: new Model(type: BookingDetailsRequest::class),
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
public function getBookingDetails(
|
||||||
|
BookingRepository $repoBooking,
|
||||||
|
#[MapRequestPayload()] BookingDetailsRequest $detailsRequest
|
||||||
|
): JsonResponse {
|
||||||
|
|
||||||
|
$selectedBooking = $repoBooking->findOneBy(["refNumber" => $detailsRequest->refNumber]);
|
||||||
|
if (\is_null($selectedBooking)) {
|
||||||
|
throw new NotFoundHttpException('Booking not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
$refNumber = $payload["refNumber"];
|
if ($selectedBooking->getBookingCustomer()->getEmail() != $detailsRequest->email) {
|
||||||
$customerEmail = $payload["email"];
|
throw new NotFoundHttpException('Booking not found');
|
||||||
|
|
||||||
$bookingList = $repoBooking->findBy(["refNumber" => $refNumber]);
|
|
||||||
if (\is_null($bookingList) || \count($bookingList) == 0) {
|
|
||||||
throw new HttpException(404, 'Invalid Booking');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$customerBooking = $bookingList[0];
|
return $this->json($selectedBooking);
|
||||||
if ($customerBooking->getBookingCustomer()->getEmail() != $customerEmail) {
|
|
||||||
throw new HttpException(404, 'Invalid Booking');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->json($customerBooking);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/booking/create', name: 'app_booking_create')]
|
/**
|
||||||
public function newBooking(Request $request, BookingRepository $repoBooking, EntityManagerInterface $entityManager,
|
* Create a new Booking.
|
||||||
RoomCategoryRepository $repoCat, RoomAvailabilityRepository $repoAvailability,
|
*/
|
||||||
PricesService $priceSrv): JsonResponse
|
#[Route('/api/booking/create', name: 'app_booking_create', methods: ["POST"], format: "json")]
|
||||||
{
|
#[OA\Tag(name: "Booking")]
|
||||||
$payload = $request->toArray();
|
#[OA\Response(
|
||||||
if (\is_null($payload)) {
|
response: 200,
|
||||||
throw new \Exception('Invalid Payload', 400);
|
description: 'Returns booking details',
|
||||||
}
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
ref: new Model(type: BookingCreateResponse::class)
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
#[OA\RequestBody(
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
ref: new Model(type: BookingCreateRequest::class),
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
public function newBooking(
|
||||||
|
EntityManagerInterface $entityManager,
|
||||||
|
RoomCategoryRepository $repoCat,
|
||||||
|
RoomAvailabilityRepository $repoAvailability,
|
||||||
|
PricesService $priceSrv,
|
||||||
|
#[MapRequestPayload()] BookingCreateRequest $createRequest
|
||||||
|
): JsonResponse {
|
||||||
|
|
||||||
$booking = new Booking();
|
$booking = new Booking();
|
||||||
try {
|
try {
|
||||||
$reqArrivalDate = $payload["arrivalDate"];
|
if ($createRequest->arrivalDate >= $createRequest->departureDate) {
|
||||||
$reqDepartureDate = $payload["departureDate"];
|
throw new ApiErrorException(
|
||||||
|
new ApiErrorMessage(422, ApiErrorMessage::TYPE_INVALID_DATE),
|
||||||
$arrivalDate = new \DateTime($reqArrivalDate);
|
'Arrival cant be before departure',
|
||||||
$departureDate = new \DateTime($reqDepartureDate);
|
);
|
||||||
|
|
||||||
if ($arrivalDate >= $departureDate) {
|
|
||||||
throw new HttpException(400, "Arrival cant be before departure");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$entityManager->beginTransaction();
|
$entityManager->beginTransaction();
|
||||||
|
|
||||||
$currentTime = new \DateTime();
|
$currentTime = new \DateTime("now");
|
||||||
|
|
||||||
// Create booking from request data.
|
// Create booking from request data.
|
||||||
$booking->setBookingTime($currentTime);
|
$booking->setBookingTime($currentTime);
|
||||||
$booking->setArrivalDate($arrivalDate);
|
$booking->setArrivalDate($createRequest->arrivalDate);
|
||||||
$booking->setDepartureDate($departureDate);
|
$booking->setDepartureDate($createRequest->departureDate);
|
||||||
|
$booking->setBookingCustomer($createRequest->customerDetails);
|
||||||
|
|
||||||
|
//TODOME: Improve refNumber generation.
|
||||||
$highest_id = $entityManager->createQueryBuilder()
|
$highest_id = $entityManager->createQueryBuilder()
|
||||||
->select('MAX(e.id)')
|
->select('MAX(e.id)')
|
||||||
->from('App\Entity\Booking', 'e')
|
->from('App\Entity\Booking', 'e')
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->getSingleScalarResult();
|
->getSingleScalarResult();
|
||||||
|
|
||||||
$booking->setRefNumber($currentTime->format("Y") . $highest_id + 1);
|
$booking->setRefNumber($currentTime->format("Y") . $highest_id + 1);
|
||||||
|
|
||||||
$entityManager->persist($booking);
|
$entityManager->persist($booking);
|
||||||
|
|
||||||
// Create booking customer.
|
if (\count($createRequest->rooms) == 0) {
|
||||||
$reqCustomer = $payload["customerDetails"];
|
throw new ApiErrorException(
|
||||||
$bookingCustomer = new BookingCustomer();
|
new ApiErrorMessage(422, ApiErrorMessage::TYPE_VALIDATION_ERROR),
|
||||||
$bookingCustomer->setName($reqCustomer["name"]);
|
'Booking must contain rooms',
|
||||||
$bookingCustomer->setSurname($reqCustomer["surname"]);
|
);
|
||||||
$bookingCustomer->setEmail($reqCustomer["email"]);
|
|
||||||
$bookingCustomer->setPhoneNumber($reqCustomer["phoneNumber"]);
|
|
||||||
$bookingCustomer->setBooking($booking);
|
|
||||||
|
|
||||||
$entityManager->persist($bookingCustomer);
|
|
||||||
|
|
||||||
$reqRoomList = $payload["rooms"];
|
|
||||||
if (\count($reqRoomList) == 0) {
|
|
||||||
throw new HttpException(400, "Se debe indicar al menos una habitación");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create each room.
|
// Create each room.
|
||||||
foreach ($reqRoomList as $roomItem) {
|
foreach ($createRequest->rooms as $roomItem) {
|
||||||
$room = new BookingRoom();
|
$room = new BookingRoom();
|
||||||
$room->setBooking($booking);
|
$room->setBooking($booking);
|
||||||
|
|
||||||
//Get Room category.
|
//Get Room category.
|
||||||
$roomCategory = $repoCat->find($roomItem["roomCategory"]);
|
$roomCategory = $repoCat->find($roomItem->roomCategory);
|
||||||
if ($roomCategory == null) {
|
if ($roomCategory == null) {
|
||||||
throw new HttpException(400, "La RoomCategory no es válida.");
|
throw new ApiErrorException(
|
||||||
|
new ApiErrorMessage(422, ApiErrorMessage::TYPE_VALIDATION_ERROR),
|
||||||
|
'Invalid RoomCategory: ' . $roomItem->roomCategory,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check room availability.
|
//Check room availability.
|
||||||
$amountAvailable = $repoAvailability->getAvailabilityForCategoryInPeriod($roomCategory, $arrivalDate, $departureDate);
|
$amountAvailable = $repoAvailability->getAvailabilityForCategoryInPeriod($roomCategory, $createRequest->arrivalDate, $createRequest->departureDate);
|
||||||
$selectedAmount = $roomItem['amount'];
|
$selectedAmount = $roomItem->amount;
|
||||||
$selectedGuestAmount = $roomItem["guestNumber"];
|
$selectedGuestAmount = $roomItem->guestNumber;
|
||||||
|
|
||||||
if($amountAvailable == null || $selectedAmount > $amountAvailable) {
|
if ($amountAvailable == null || $selectedAmount > $amountAvailable) {
|
||||||
throw new HttpException(400, "No se pueden reservar más habitaciones de las disponibles.");
|
throw new ApiErrorException(
|
||||||
|
new ApiErrorMessage(400, ApiErrorMessage::TYPE_LOGICAL_ERROR),
|
||||||
|
'Not enought rooms available for category: ' . $roomItem->roomCategory,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$room->setRoomCategory($roomCategory);
|
$room->setRoomCategory($roomCategory);
|
||||||
@@ -125,30 +155,31 @@ class BookingController extends AbstractController
|
|||||||
$room->setAmount($selectedAmount);
|
$room->setAmount($selectedAmount);
|
||||||
|
|
||||||
//Get Price for period.
|
//Get Price for period.
|
||||||
$priceList = $priceSrv->getFinalPricesForSearch($roomCategory, $arrivalDate, $departureDate);
|
$priceList = $priceSrv->getFinalPricesForSearch($roomCategory, $createRequest->arrivalDate, $createRequest->departureDate);
|
||||||
$priceFound = false;
|
$priceFound = false;
|
||||||
foreach ($priceList as $key => $value) {
|
foreach ($priceList as $key => $value) {
|
||||||
if($key == $selectedGuestAmount) {
|
if ($key == $selectedGuestAmount) {
|
||||||
$room->setRoomPrice($value);
|
$room->setRoomPrice($value);
|
||||||
$priceFound = true;
|
$priceFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$priceFound) {
|
if (!$priceFound) {
|
||||||
throw new HttpException(500,
|
throw new ApiErrorException(
|
||||||
"No se puedo obtener el precio para la categoría: " . $roommCategory->getId() . " , guests: " . $selecctedGuestAmount);
|
new ApiErrorMessage(422, ApiErrorMessage::TYPE_LOGICAL_ERROR),
|
||||||
|
'Price not found for category: ' . $roomCategory->getId() . ', guests: ' . $selectedGuestAmount,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entityManager->persist($room);
|
$entityManager->persist($room);
|
||||||
|
|
||||||
//If booking is nice, let's update current availability.
|
//If booking is nice, let's update current availability.
|
||||||
$repoAvailability->updateAvailabilityForRoomCategoryOnPeriod($roomCategory, $arrivalDate, $departureDate, $selectedAmount, true); //Update using "diff" mode.
|
$repoAvailability->updateAvailabilityForRoomCategoryOnPeriod($roomCategory, $createRequest->arrivalDate, $createRequest->departureDate, $selectedAmount, true); //Update using "diff" mode.
|
||||||
}
|
}
|
||||||
|
|
||||||
$entityManager->commit();
|
$entityManager->commit();
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
|
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
$entityManager->rollback();
|
$entityManager->rollback();
|
||||||
throw $th;
|
throw $th;
|
||||||
|
|||||||
@@ -2,14 +2,37 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\ApiErrorException;
|
||||||
|
use App\DTO\ApiErrorMessage;
|
||||||
|
use App\Entity\ConfigVariable;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use App\Repository\ConfigVariableRepository;
|
use App\Repository\ConfigVariableRepository;
|
||||||
|
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||||
|
use OpenApi\Attributes as OA;
|
||||||
|
|
||||||
class ConfigVariableController extends AbstractController
|
class ConfigVariableController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/api/config', name: 'app_config_variable')]
|
/**
|
||||||
|
* Get All config variables.
|
||||||
|
*/
|
||||||
|
#[Route('/api/config', name: 'app_config_allVariable', methods: ["GET"])]
|
||||||
|
#[OA\Tag(name: "Config")]
|
||||||
|
#[OA\Response(
|
||||||
|
response: 200,
|
||||||
|
description: 'Returns all public config variables.',
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
properties: [
|
||||||
|
new OA\Property(
|
||||||
|
property: "results",
|
||||||
|
type: "array",
|
||||||
|
items: new OA\Items(ref: new Model(type: ConfigVariable::class))
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)]
|
||||||
public function getAllVariables(ConfigVariableRepository $repo): Response
|
public function getAllVariables(ConfigVariableRepository $repo): Response
|
||||||
{
|
{
|
||||||
$varList = $repo->findAllVariables();
|
$varList = $repo->findAllVariables();
|
||||||
@@ -17,7 +40,22 @@ class ConfigVariableController extends AbstractController
|
|||||||
return $this->json(['results' => $varList]);
|
return $this->json(['results' => $varList]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/config/section', name: 'app_config_sections')]
|
#[Route('/api/config/section', name: 'app_config_sections', methods: ["GET"])]
|
||||||
|
#[OA\Tag(name: "Config")]
|
||||||
|
#[OA\Response(
|
||||||
|
response: 200,
|
||||||
|
description: 'Returns all public config sections.',
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
properties: [
|
||||||
|
new OA\Property(
|
||||||
|
property: "results",
|
||||||
|
type: "array",
|
||||||
|
items: new OA\Items(type: "string")
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)]
|
||||||
public function getSections(ConfigVariableRepository $repo): Response
|
public function getSections(ConfigVariableRepository $repo): Response
|
||||||
{
|
{
|
||||||
$sectionList = $repo->getAllSections();
|
$sectionList = $repo->getAllSections();
|
||||||
@@ -30,11 +68,34 @@ class ConfigVariableController extends AbstractController
|
|||||||
return $this->json(['results' => $returnList]);
|
return $this->json(['results' => $returnList]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/config/section/{section}', name: 'app_config_variableBySection')]
|
#[Route('/api/config/section/{section}', name: 'app_config_variableBySection', methods: ["GET"])]
|
||||||
|
#[OA\Tag(name: "Config")]
|
||||||
|
#[OA\Response(
|
||||||
|
response: 200,
|
||||||
|
description: 'Returns all public config variables for given section.',
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
properties: [
|
||||||
|
new OA\Property(
|
||||||
|
property: "results",
|
||||||
|
type: "array",
|
||||||
|
items: new OA\Items(ref: new Model(type: ConfigVariable::class))
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
#[OA\Parameter(
|
||||||
|
name: 'section',
|
||||||
|
in: 'path',
|
||||||
|
description: 'Config section.',
|
||||||
|
schema: new OA\Schema(type: 'string')
|
||||||
|
)]
|
||||||
public function getVariablesBySection(ConfigVariableRepository $repo, string $section): Response
|
public function getVariablesBySection(ConfigVariableRepository $repo, string $section): Response
|
||||||
{
|
{
|
||||||
if(\is_null($section) || $section == '') {
|
if(\is_null($section) || $section == '') {
|
||||||
return new Response("Invalid section value", 404);
|
throw new ApiErrorException(
|
||||||
|
new ApiErrorMessage(400, ApiErrorMessage::TYPE_INVALID_REQUEST_BODY_FORMAT)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$varList = $repo->findAllBySection($section);
|
$varList = $repo->findAllBySection($section);
|
||||||
@@ -42,7 +103,22 @@ class ConfigVariableController extends AbstractController
|
|||||||
return $this->json(['results' => $varList]);
|
return $this->json(['results' => $varList]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/config/var/{key}', name: 'app_config_variable')]
|
#[Route('/api/config/var/{key}', name: 'app_config_variable', methods: ["GET"])]
|
||||||
|
#[OA\Tag(name: "Config")]
|
||||||
|
#[OA\Response(
|
||||||
|
response: 200,
|
||||||
|
description: 'Get config variable by key.',
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
ref: new Model(type: ConfigVariable::class),
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
#[OA\Parameter(
|
||||||
|
name: 'key',
|
||||||
|
in: 'path',
|
||||||
|
description: 'Variable key.',
|
||||||
|
schema: new OA\Schema(type: 'string')
|
||||||
|
)]
|
||||||
public function getByKey(ConfigVariableRepository $repo, string $key): Response
|
public function getByKey(ConfigVariableRepository $repo, string $key): Response
|
||||||
{
|
{
|
||||||
$var = $repo->findVariableByKey($key);
|
$var = $repo->findVariableByKey($key);
|
||||||
|
|||||||
@@ -6,18 +6,37 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use App\Repository\RoomCategoryRepository;
|
use App\Repository\RoomCategoryRepository;
|
||||||
use App\Entity\RoomCategory;
|
use App\Entity\RoomCategory;
|
||||||
use App\Entity\RoomCategoryDetails;
|
|
||||||
use App\Entity\RoomCategoryPhoto;
|
use App\Entity\RoomCategoryPhoto;
|
||||||
|
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||||
|
use OpenApi\Annotations\Property;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use OpenApi\Attributes as OA;
|
||||||
use Symfony\Component\Serializer\Context\Normalizer\ObjectNormalizerContextBuilder;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
|
||||||
class RoomCategoryController extends AbstractController
|
class RoomCategoryController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
#[Route('/api/room/category', name: 'app_room_AllCategories')]
|
/**
|
||||||
|
* Get All room categories.
|
||||||
|
*/
|
||||||
|
#[Route('/api/room/category', name: 'app_room_AllCategories', methods: ["GET"])]
|
||||||
|
#[OA\Tag(name: "Rooms")]
|
||||||
|
#[OA\Response(
|
||||||
|
response: 200,
|
||||||
|
description: 'Returns all room categories',
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
properties: [
|
||||||
|
new OA\Property(
|
||||||
|
property: "results",
|
||||||
|
type: "array",
|
||||||
|
items: new OA\Items(ref: new Model(type: RoomCategory::class))
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)]
|
||||||
public function getAll(RoomCategoryRepository $catRepo): Response
|
public function getAll(RoomCategoryRepository $catRepo): Response
|
||||||
{
|
{
|
||||||
$catList = $catRepo->findAll();
|
$catList = $catRepo->findAll();
|
||||||
@@ -25,7 +44,24 @@ class RoomCategoryController extends AbstractController
|
|||||||
return $this->json(["results" => $catList]);
|
return $this->json(["results" => $catList]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/room/category/{id}', name: 'app_room_category')]
|
/**
|
||||||
|
* Get a room category by ID.
|
||||||
|
*/
|
||||||
|
#[Route('/api/room/category/{id}', name: 'app_room_category', methods: ["GET"])]
|
||||||
|
#[OA\Tag(name: "Rooms")]
|
||||||
|
#[OA\Response(
|
||||||
|
response: 200,
|
||||||
|
description: 'Returns a room category',
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
ref: new Model(type: RoomCategory::class),
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
#[OA\Parameter(
|
||||||
|
name: 'id',
|
||||||
|
in: 'path',
|
||||||
|
description: 'RoomCategory ID',
|
||||||
|
)]
|
||||||
public function getById(RoomCategory $category): Response
|
public function getById(RoomCategory $category): Response
|
||||||
{
|
{
|
||||||
return $this->json($category);
|
return $this->json($category);
|
||||||
|
|||||||
@@ -2,95 +2,136 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Repository\FareTableRepository;
|
use App\ApiErrorException;
|
||||||
|
use App\DTO\ApiErrorMessage;
|
||||||
use App\Repository\RoomAvailabilityRepository;
|
use App\Repository\RoomAvailabilityRepository;
|
||||||
use App\Repository\RoomCategoryRepository;
|
use App\Repository\RoomCategoryRepository;
|
||||||
|
use App\Request\SearchAvailabilityPeriodRequest;
|
||||||
|
use App\Response\SearchAvailabilityResponse;
|
||||||
|
use App\Request\SearchPricesForCategoryRequest;
|
||||||
|
use App\Response\SearchPricesForCategoryResponse;
|
||||||
use App\Service\PricesService;
|
use App\Service\PricesService;
|
||||||
|
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use OpenApi\Attributes as OA;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
|
||||||
|
|
||||||
class SearchRoomsController extends AbstractController
|
class SearchRoomsController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/api/search/availability', name: 'app_search_availability')]
|
/**
|
||||||
public function getAvailabilityForPeriod(Request $request, RoomAvailabilityRepository $repoAvailability): Response
|
* Get availability for all rooms on period.
|
||||||
{
|
* For each room, the minimal availability will be returned.
|
||||||
$payload = $request->toArray();
|
*/
|
||||||
if (\is_null($payload)) {
|
#[Route('/api/search/availability', name: 'app_search_availability', methods: ["POST"], format: "json")]
|
||||||
throw new \Exception('Invalid Payload', 400);
|
#[OA\Tag(name: "Searchs")]
|
||||||
|
#[OA\Response(
|
||||||
|
response: 200,
|
||||||
|
description: 'Each room available',
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
properties: [
|
||||||
|
new OA\Property(
|
||||||
|
property: "results",
|
||||||
|
type: "array",
|
||||||
|
items: new OA\Items(ref: new Model(type: SearchAvailabilityResponse::class))
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
#[OA\RequestBody(
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
ref: new Model(type: SearchAvailabilityPeriodRequest::class),
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
public function getAvailabilityForPeriod(
|
||||||
|
RoomAvailabilityRepository $repoAvailability,
|
||||||
|
#[MapRequestPayload()] SearchAvailabilityPeriodRequest $searchRequest
|
||||||
|
): JsonResponse {
|
||||||
|
|
||||||
|
if ($searchRequest->startDate >= $searchRequest->endDate) {
|
||||||
|
throw new ApiErrorException(
|
||||||
|
new ApiErrorMessage(422, ApiErrorMessage::TYPE_INVALID_DATE),
|
||||||
|
'startDate cant be before endDate',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$filter = $payload["filter"];
|
$rs = $repoAvailability->getAvailabilityForPeriod($searchRequest->startDate, $searchRequest->endDate);
|
||||||
|
|
||||||
$startDate = new \DateTime($filter["startDate"]);
|
|
||||||
$endDate = new \DateTime($filter["endDate"]);
|
|
||||||
|
|
||||||
$rs = $repoAvailability->getAvailabilityForPeriod($startDate, $endDate);
|
|
||||||
|
|
||||||
return $this->json(["results" => $rs]);
|
return $this->json(["results" => $rs]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/search/availabilityDetails', name: 'app_search_availabilityDetails')]
|
/**
|
||||||
public function getAvailabilityForPeriodDetails(Request $request, RoomAvailabilityRepository $repoAvailability): Response
|
* Get Availability for all rooms on each day of a period.
|
||||||
{
|
* (Not used on Front-end APP)
|
||||||
$payload = $request->toArray();
|
*/
|
||||||
if (\is_null($payload)) {
|
#[Route('/api/search/availabilityDetails', name: 'app_search_availabilityDetails', methods: ["POST"], format: "json")]
|
||||||
throw new \Exception('Invalid Payload', 400);
|
#[OA\Tag(name: "Searchs")]
|
||||||
}
|
public function getAvailabilityForPeriodDetails(
|
||||||
$filter = $payload["filter"];
|
RoomAvailabilityRepository $repoAvailability,
|
||||||
|
#[MapRequestPayload()] SearchAvailabilityPeriodRequest $searchRequest
|
||||||
|
): JsonResponse {
|
||||||
|
|
||||||
$startDate = new \DateTime($filter["startDate"]);
|
$rs = $repoAvailability->getAvailabilityForPeriodDetails($searchRequest->startDate, $searchRequest->endDate);
|
||||||
$endDate = new \DateTime($filter["endDate"]);
|
|
||||||
|
|
||||||
$rs = $repoAvailability->getAvailabilityForPeriodDetails($startDate, $endDate);
|
return $this->json(["results" => $rs]);
|
||||||
|
|
||||||
return $this->json($rs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/search/fares', name: 'app_search_faresForCategory')]
|
/**
|
||||||
public function getFaresForCategoryOnPeriod(Request $request, RoomCategoryRepository $repoCat, PricesService $priceService): Response
|
* Get room category price for given period.
|
||||||
{
|
* Returns price for a room category.
|
||||||
$payload = $request->toArray();
|
* This price is the total for all the selected days by guest number.
|
||||||
if (\is_null($payload)) {
|
*/
|
||||||
throw new \Exception('Invalid Payload', 400);
|
#[Route('/api/search/prices', name: 'app_search_pricesForCategory', methods: ["POST"], format: "json")]
|
||||||
}
|
#[OA\Tag(name: "Searchs")]
|
||||||
$filter = $payload["filter"];
|
#[OA\Response(
|
||||||
|
response: 200,
|
||||||
|
description: 'Room price by guest number',
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
properties: [
|
||||||
|
new OA\Property(
|
||||||
|
property: "results",
|
||||||
|
type: "array",
|
||||||
|
items: new OA\Items(ref: new Model(type: SearchPricesForCategoryResponse::class))
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
#[OA\RequestBody(
|
||||||
|
content: new OA\JsonContent(
|
||||||
|
type: 'object',
|
||||||
|
ref: new Model(type: SearchPricesForCategoryRequest::class),
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
public function getPricesForCategoryOnPeriod(
|
||||||
|
RoomCategoryRepository $repoCat,
|
||||||
|
PricesService $priceService,
|
||||||
|
#[MapRequestPayload()] SearchPricesForCategoryRequest $searchRequest
|
||||||
|
): JsonResponse {
|
||||||
|
|
||||||
$catId = $filter["roomCategory"];
|
$roomCategory = $repoCat->find($searchRequest->roomCategory);
|
||||||
$roomCategory = $repoCat->find($catId);
|
|
||||||
if ($roomCategory === null) {
|
if ($roomCategory === null) {
|
||||||
throw new \Exception('Invalid Category', 400);
|
throw new ApiErrorException(
|
||||||
|
new ApiErrorMessage(422, ApiErrorMessage::TYPE_VALIDATION_ERROR),
|
||||||
|
'Invalid RoomCategory: ' . $searchRequest->roomCategory,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$startDate = new \DateTime($filter["startDate"]);
|
if ($searchRequest->startDate >= $searchRequest->endDate) {
|
||||||
$endDate = new \DateTime($filter["endDate"]);
|
throw new ApiErrorException(
|
||||||
|
new ApiErrorMessage(422, ApiErrorMessage::TYPE_INVALID_DATE),
|
||||||
$daysDiff = $startDate->diff($endDate)->days;
|
'startDate cant be before endDate',
|
||||||
if (!$daysDiff || $startDate > $endDate) {
|
);
|
||||||
throw new \Exception('Invalid time interval', 400);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$fareList = $priceService->getFinalPricesForSearch($roomCategory, $startDate, $endDate);
|
$fareList = $priceService->getFinalPricesForSearch($roomCategory, $searchRequest->startDate, $searchRequest->endDate);
|
||||||
$rs = [];
|
$rs = [];
|
||||||
foreach ($fareList as $key => $value) {
|
foreach ($fareList as $key => $value) {
|
||||||
$rs[] = [ "guestNumber" => $key, "price" => $value];
|
$rs[] = ["guestNumber" => $key, "price" => $value];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->json(["results" => $rs]);
|
return $this->json(["results" => $rs]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/search/debug', name: 'app_search_faresDebug')]
|
|
||||||
public function faresDebug(Request $request, PricesService $priceService, FareTableRepository $repoFareTable, RoomCategoryRepository $repoCat): Response
|
|
||||||
{
|
|
||||||
$fareTable[] = $repoFareTable->find(1);
|
|
||||||
$fareTable[] = $repoFareTable->find(2);
|
|
||||||
$cat = $repoCat->find(4);
|
|
||||||
|
|
||||||
$startDate = new \DateTime("2024-04-27");
|
|
||||||
$endDate = new \DateTime("2024-05-02");
|
|
||||||
|
|
||||||
$rs = $priceService->getFinalPricesForSearch($cat, $startDate, $endDate);
|
|
||||||
|
|
||||||
return $this->json($rs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\User;
|
|
||||||
use App\Entity\ConfigVariable;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||||
|
|
||||||
@@ -33,53 +29,4 @@ class SecurityController extends AbstractController
|
|||||||
{
|
{
|
||||||
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
|
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#[Route(path: '/setup', name: 'app_security_addAdmin')]
|
|
||||||
public function addAdmin(UserPasswordHasherInterface $passwordHasher, EntityManagerInterface $entityManager): Response
|
|
||||||
{
|
|
||||||
$configRepo = $entityManager->getRepository(ConfigVariable::class);
|
|
||||||
$setupStatus = $configRepo->findBy(["key" => "SETUP_STATUS"]);
|
|
||||||
|
|
||||||
if($setupStatus != null && $setupStatus[0] != null && $setupStatus[0]->getValue() != 1) {
|
|
||||||
return new Response("Setup was already done");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$entityManager->beginTransaction();
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
//Create system variables.
|
|
||||||
$var_setup = new ConfigVariable();
|
|
||||||
$var_setup->setKey("SETUP_STATUS");
|
|
||||||
$var_setup->setValue("1");
|
|
||||||
$var_setup->setSection("SYSTEM");
|
|
||||||
$entityManager->persist($var_setup);
|
|
||||||
|
|
||||||
|
|
||||||
//Create user Admin.
|
|
||||||
$user = new User();
|
|
||||||
$user->setUsername("admin");
|
|
||||||
$user->setRoles(["ROLE_USER", "ROLE_ADMIN", "ROLE_SUPERADMIN"]);
|
|
||||||
$plaintextPassword = "admin";
|
|
||||||
|
|
||||||
// hash the password (based on the security.yaml config for the $user class)
|
|
||||||
$hashedPassword = $passwordHasher->hashPassword(
|
|
||||||
$user,
|
|
||||||
$plaintextPassword
|
|
||||||
);
|
|
||||||
$user->setPassword($hashedPassword);
|
|
||||||
|
|
||||||
$entityManager->persist($user);
|
|
||||||
|
|
||||||
$entityManager->flush();
|
|
||||||
$entityManager->commit();
|
|
||||||
|
|
||||||
} catch (\Throwable $th) {
|
|
||||||
$entityManager->rollback();
|
|
||||||
throw $th;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Response("Setup completed :)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DTO;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class ApiErrorMessage
|
||||||
|
{
|
||||||
|
const TYPE_VALIDATION_ERROR = 'validation_error';
|
||||||
|
const TYPE_INVALID_REQUEST_BODY_FORMAT = 'invalid_body_format';
|
||||||
|
const TYPE_LOGICAL_ERROR = 'logical_error';
|
||||||
|
const TYPE_SERVER_ERROR = 'server_error';
|
||||||
|
const TYPE_INVALID_DATE = 'invalid_date';
|
||||||
|
|
||||||
|
private static $titles = array(
|
||||||
|
self::TYPE_VALIDATION_ERROR => 'There was a validation error',
|
||||||
|
self::TYPE_INVALID_REQUEST_BODY_FORMAT => 'Invalid JSON format sent',
|
||||||
|
self::TYPE_LOGICAL_ERROR => 'Invalid request due to a logic error',
|
||||||
|
self::TYPE_SERVER_ERROR => 'Error on server side',
|
||||||
|
self::TYPE_INVALID_DATE => 'Invalid date on request',
|
||||||
|
);
|
||||||
|
|
||||||
|
private int $statusCode;
|
||||||
|
private string $type;
|
||||||
|
private string $title;
|
||||||
|
private array $extraData = array();
|
||||||
|
|
||||||
|
public function __construct($statusCode, $type = null)
|
||||||
|
{
|
||||||
|
if ($type === null) {
|
||||||
|
// no type? The default is about:blank and the title should
|
||||||
|
// be the standard status code message
|
||||||
|
$type = 'about:blank';
|
||||||
|
$title = isset(Response::$statusTexts[$statusCode]) ?
|
||||||
|
Response::$statusTexts[$statusCode] : 'Unknown status code :(';
|
||||||
|
} else {
|
||||||
|
if (!isset(self::$titles[$type])) {
|
||||||
|
throw new \InvalidArgumentException('No title for type ' . $type);
|
||||||
|
}
|
||||||
|
$title = self::$titles[$type];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->statusCode = $statusCode;
|
||||||
|
$this->type = $type;
|
||||||
|
$this->title = $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStatusCode(): int
|
||||||
|
{
|
||||||
|
return $this->statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return $this->title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setExtraData($name, $value)
|
||||||
|
{
|
||||||
|
$this->extraData[$name] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDetails($value)
|
||||||
|
{
|
||||||
|
$this->extraData['details'] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function toArray(): array
|
||||||
|
{
|
||||||
|
return array_merge(
|
||||||
|
$this->extraData,
|
||||||
|
array(
|
||||||
|
'status' => $this->statusCode,
|
||||||
|
'type' => $this->type,
|
||||||
|
'title' => $this->title,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DTO;
|
||||||
|
|
||||||
|
class AppSetupConfig
|
||||||
|
{
|
||||||
|
protected string $adminUser;
|
||||||
|
protected string $adminPass;
|
||||||
|
|
||||||
|
protected bool $genExampleData;
|
||||||
|
|
||||||
|
public function getAdminUser(): string
|
||||||
|
{
|
||||||
|
return $this->adminUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAdminUser(string $adminUser): void
|
||||||
|
{
|
||||||
|
$this->adminUser = $adminUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAdminPass(): string
|
||||||
|
{
|
||||||
|
return $this->adminPass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAdminPass(string $adminPass): void
|
||||||
|
{
|
||||||
|
$this->adminPass = $adminPass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGenExampleData(): bool
|
||||||
|
{
|
||||||
|
return $this->genExampleData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGenExampleData(bool $genExampleData): void
|
||||||
|
{
|
||||||
|
$this->genExampleData = $genExampleData;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\DTO;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
|
||||||
|
class ExampleDataConfig
|
||||||
|
{
|
||||||
|
protected DateTime $startDate;
|
||||||
|
protected DateTime $endDate;
|
||||||
|
|
||||||
|
protected bool $genRoomCategories;
|
||||||
|
|
||||||
|
protected bool $genFaretables;
|
||||||
|
protected bool $genAvailability;
|
||||||
|
protected string $genMode;
|
||||||
|
|
||||||
|
public const GENMODE_EXAMPLE = "EXAMPLE";
|
||||||
|
public const GENMODE_RANDOM = "RANDOM";
|
||||||
|
|
||||||
|
public function getStartDate(): DateTime
|
||||||
|
{
|
||||||
|
return $this->startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStartDate(DateTime $startDate): void
|
||||||
|
{
|
||||||
|
$this->startDate = $startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEndDate(): DateTime
|
||||||
|
{
|
||||||
|
return $this->endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEndDate(DateTime $endDate): void
|
||||||
|
{
|
||||||
|
$this->endDate = $endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGenRoomCategories(): bool
|
||||||
|
{
|
||||||
|
return $this->genRoomCategories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGenRoomCategories(bool $genRoomCategories): void
|
||||||
|
{
|
||||||
|
$this->genRoomCategories = $genRoomCategories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGenFaretables(): bool
|
||||||
|
{
|
||||||
|
return $this->genFaretables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGenFaretables(bool $genFaretables): void
|
||||||
|
{
|
||||||
|
$this->genFaretables = $genFaretables;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGenAvailability(): bool
|
||||||
|
{
|
||||||
|
return $this->genAvailability;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGenAvailability(bool $genAvailability): void
|
||||||
|
{
|
||||||
|
$this->genAvailability = $genAvailability;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getGenMode(): string
|
||||||
|
{
|
||||||
|
return $this->genMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setGenMode(string $genMode): void
|
||||||
|
{
|
||||||
|
$this->genMode = $genMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\BedTypeRepository;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Ignore;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: BedTypeRepository::class)]
|
||||||
|
class BedType
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\GeneratedValue]
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $name = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $iconUrl = null;
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(string $name): static
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIconUrl(): ?string
|
||||||
|
{
|
||||||
|
return $this->iconUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIconUrl(?string $iconUrl): static
|
||||||
|
{
|
||||||
|
$this->iconUrl = $iconUrl;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __toString(): string {
|
||||||
|
return $this->getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
-17
@@ -7,6 +7,7 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\DBAL\Types\Types;
|
use Doctrine\DBAL\Types\Types;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Ignore;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: BookingRepository::class)]
|
#[ORM\Entity(repositoryClass: BookingRepository::class)]
|
||||||
class Booking
|
class Booking
|
||||||
@@ -14,29 +15,30 @@ class Booking
|
|||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
|
#[Ignore]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 20)]
|
||||||
|
private ?string $refNumber = null;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
#[ORM\Column(type: Types::DATE_MUTABLE)]
|
||||||
private ?\DateTimeInterface $ArrivalDate = null;
|
private ?\DateTimeInterface $arrivalDate = null;
|
||||||
|
|
||||||
#[ORM\Column(type : Types::DATE_MUTABLE)]
|
#[ORM\Column(type : Types::DATE_MUTABLE)]
|
||||||
private ?\DateTimeInterface $DepartureDate = null;
|
private ?\DateTimeInterface $departureDate = null;
|
||||||
|
|
||||||
#[ORM\Column(type : Types::DATETIMETZ_MUTABLE)]
|
#[ORM\Column(type : Types::DATETIMETZ_MUTABLE)]
|
||||||
private ?\DateTimeInterface $BookingTime = null;
|
private ?\DateTimeInterface $bookingTime = null;
|
||||||
|
|
||||||
#[ORM\OneToOne(mappedBy : 'Booking', cascade: ['persist', 'remove'])]
|
#[ORM\OneToOne(mappedBy: 'booking', cascade: ['persist', 'remove'])]
|
||||||
private ?BookingCustomer $bookingCustomer = null;
|
private ?BookingCustomer $bookingCustomer = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection<int, BookingRoom>
|
* @var Collection<int, BookingRoom>
|
||||||
*/
|
*/
|
||||||
#[ORM\OneToMany(targetEntity: BookingRoom::class, mappedBy: 'Booking', orphanRemoval: true, cascade: ['persist'])]
|
#[ORM\OneToMany(targetEntity: BookingRoom::class, mappedBy: 'booking', orphanRemoval: true, cascade: ['persist'])]
|
||||||
private Collection $bookingRooms;
|
private Collection $bookingRooms;
|
||||||
|
|
||||||
#[ORM\Column(length: 20)]
|
|
||||||
private ?string $refNumber = null;
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->bookingRooms = new ArrayCollection();
|
$this->bookingRooms = new ArrayCollection();
|
||||||
@@ -49,36 +51,36 @@ class Booking
|
|||||||
|
|
||||||
public function getArrivalDate(): ?\DateTimeInterface
|
public function getArrivalDate(): ?\DateTimeInterface
|
||||||
{
|
{
|
||||||
return $this->ArrivalDate;
|
return $this->arrivalDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setArrivalDate(\DateTimeInterface $ArrivalDate): static
|
public function setArrivalDate(\DateTimeInterface $arrivalDate): static
|
||||||
{
|
{
|
||||||
$this->ArrivalDate = $ArrivalDate;
|
$this->arrivalDate = $arrivalDate;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDepartureDate(): ?\DateTimeInterface
|
public function getDepartureDate(): ?\DateTimeInterface
|
||||||
{
|
{
|
||||||
return $this->DepartureDate;
|
return $this->departureDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setDepartureDate(\DateTimeInterface $DepartureDate): static
|
public function setDepartureDate(\DateTimeInterface $departureDate): static
|
||||||
{
|
{
|
||||||
$this->DepartureDate = $DepartureDate;
|
$this->departureDate = $departureDate;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBookingTime(): ?\DateTimeInterface
|
public function getBookingTime(): ?\DateTimeInterface
|
||||||
{
|
{
|
||||||
return $this->BookingTime;
|
return $this->bookingTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBookingTime(\DateTimeInterface $BookingTime): static
|
public function setBookingTime(\DateTimeInterface $bookingTime): static
|
||||||
{
|
{
|
||||||
$this->BookingTime = $BookingTime;
|
$this->bookingTime = $bookingTime;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Entity;
|
|||||||
use App\Repository\BookingCustomerRepository;
|
use App\Repository\BookingCustomerRepository;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Annotation\Ignore;
|
use Symfony\Component\Serializer\Annotation\Ignore;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: BookingCustomerRepository::class)]
|
#[ORM\Entity(repositoryClass: BookingCustomerRepository::class)]
|
||||||
class BookingCustomer
|
class BookingCustomer
|
||||||
@@ -12,88 +13,92 @@ class BookingCustomer
|
|||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
|
#[Ignore]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\OneToOne(inversedBy: 'bookingCustomer', cascade: ['persist', 'remove'])]
|
#[ORM\OneToOne(inversedBy: 'bookingCustomer', cascade: ['persist', 'remove'])]
|
||||||
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
||||||
#[Ignore]
|
#[Ignore]
|
||||||
private ?Booking $Booking = null;
|
private ?Booking $booking = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 64)]
|
#[ORM\Column(length: 64)]
|
||||||
private ?string $Name = null;
|
#[Assert\NotBlank]
|
||||||
|
private ?string $name = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
private ?string $Surname = null;
|
#[Assert\NotBlank]
|
||||||
|
private ?string $surname = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
private ?string $Email = null;
|
#[Assert\NotBlank]
|
||||||
|
#[Assert\Email]
|
||||||
|
private ?string $email = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255)]
|
||||||
private ?string $PhoneNumber = null;
|
#[Assert\NotBlank]
|
||||||
|
private ?string $phoneNumber = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Ignore]
|
|
||||||
public function getBooking(): ?Booking
|
public function getBooking(): ?Booking
|
||||||
{
|
{
|
||||||
return $this->Booking;
|
return $this->booking;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Ignore]
|
public function setBooking(Booking $booking): static
|
||||||
public function setBooking(Booking $Booking): static
|
|
||||||
{
|
{
|
||||||
$this->Booking = $Booking;
|
$this->booking = $booking;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): ?string
|
public function getName(): ?string
|
||||||
{
|
{
|
||||||
return $this->Name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setName(string $Name): static
|
public function setName(string $name): static
|
||||||
{
|
{
|
||||||
$this->Name = $Name;
|
$this->name = $name;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSurname(): ?string
|
public function getSurname(): ?string
|
||||||
{
|
{
|
||||||
return $this->Surname;
|
return $this->surname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSurname(string $Surname): static
|
public function setSurname(string $surname): static
|
||||||
{
|
{
|
||||||
$this->Surname = $Surname;
|
$this->surname = $surname;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmail(): ?string
|
public function getEmail(): ?string
|
||||||
{
|
{
|
||||||
return $this->Email;
|
return $this->email;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEmail(string $Email): static
|
public function setEmail(string $email): static
|
||||||
{
|
{
|
||||||
$this->Email = $Email;
|
$this->email = $email;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPhoneNumber(): ?string
|
public function getPhoneNumber(): ?string
|
||||||
{
|
{
|
||||||
return $this->PhoneNumber;
|
return $this->phoneNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPhoneNumber(string $PhoneNumber): static
|
public function setPhoneNumber(string $phoneNumber): static
|
||||||
{
|
{
|
||||||
$this->PhoneNumber = $PhoneNumber;
|
$this->phoneNumber = $phoneNumber;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-24
@@ -12,56 +12,53 @@ class BookingRoom
|
|||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
|
#[Ignore]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'bookingRooms')]
|
#[ORM\ManyToOne(inversedBy: 'bookingRooms')]
|
||||||
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
||||||
#[Ignore]
|
#[Ignore]
|
||||||
private ?Booking $Booking = null;
|
private ?Booking $booking = null;
|
||||||
|
|
||||||
#[ORM\ManyToOne]
|
#[ORM\ManyToOne]
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
#[Ignore]
|
#[Ignore]
|
||||||
private ?RoomCategory $RoomCategory = null;
|
private ?RoomCategory $roomCategory = null;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
private ?int $GuestNumber = null;
|
private ?int $guestNumber = null;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
private ?int $RoomPrice = null;
|
private ?int $roomPrice = null;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
private ?int $Amount = null;
|
private ?int $amount = null;
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Ignore]
|
|
||||||
public function getBooking(): ?Booking
|
public function getBooking(): ?Booking
|
||||||
{
|
{
|
||||||
return $this->Booking;
|
return $this->booking;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Ignore]
|
public function setBooking(?Booking $booking): static
|
||||||
public function setBooking(?Booking $Booking): static
|
|
||||||
{
|
{
|
||||||
$this->Booking = $Booking;
|
$this->booking = $booking;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Ignore]
|
|
||||||
public function getRoomCategory(): ?RoomCategory
|
public function getRoomCategory(): ?RoomCategory
|
||||||
{
|
{
|
||||||
return $this->RoomCategory;
|
return $this->roomCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Ignore]
|
public function setRoomCategory(?RoomCategory $roomCategory): static
|
||||||
public function setRoomCategory(?RoomCategory $RoomCategory): static
|
|
||||||
{
|
{
|
||||||
$this->RoomCategory = $RoomCategory;
|
$this->roomCategory = $roomCategory;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -73,36 +70,36 @@ class BookingRoom
|
|||||||
|
|
||||||
public function getGuestNumber(): ?int
|
public function getGuestNumber(): ?int
|
||||||
{
|
{
|
||||||
return $this->GuestNumber;
|
return $this->guestNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setGuestNumber(int $GuestNumber): static
|
public function setGuestNumber(int $guestNumber): static
|
||||||
{
|
{
|
||||||
$this->GuestNumber = $GuestNumber;
|
$this->guestNumber = $guestNumber;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRoomPrice(): ?int
|
public function getRoomPrice(): ?int
|
||||||
{
|
{
|
||||||
return $this->RoomPrice;
|
return $this->roomPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRoomPrice(int $RoomPrice): static
|
public function setRoomPrice(int $roomPrice): static
|
||||||
{
|
{
|
||||||
$this->RoomPrice = $RoomPrice;
|
$this->roomPrice = $roomPrice;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAmount(): ?int
|
public function getAmount(): ?int
|
||||||
{
|
{
|
||||||
return $this->Amount;
|
return $this->amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAmount(int $Amount): static
|
public function setAmount(int $amount): static
|
||||||
{
|
{
|
||||||
$this->Amount = $Amount;
|
$this->amount = $amount;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,31 +3,25 @@
|
|||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use App\Repository\ConfigVariableRepository;
|
use App\Repository\ConfigVariableRepository;
|
||||||
|
use App\Enum\ConfigSectionType;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: ConfigVariableRepository::class)]
|
#[ORM\Entity(repositoryClass: ConfigVariableRepository::class)]
|
||||||
class ConfigVariable
|
class ConfigVariable
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue("NONE")]
|
||||||
#[ORM\Column]
|
#[ORM\Column(length: 32, unique: true, nullable: false)]
|
||||||
private ?int $id = null;
|
private string $key = "";
|
||||||
|
|
||||||
#[ORM\Column(length: 32, unique: true)]
|
#[ORM\Column(length: 255, nullable: false)]
|
||||||
private ?string $key = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $value = null;
|
private ?string $value = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 64, nullable: true)]
|
#[ORM\Column(type: 'string', enumType: ConfigSectionType::class, nullable: false)]
|
||||||
private ?string $section = null;
|
private ConfigSectionType $section = ConfigSectionType::General;
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getKey(): ?string
|
public function getKey(): string
|
||||||
{
|
{
|
||||||
return $this->key;
|
return $this->key;
|
||||||
}
|
}
|
||||||
@@ -51,15 +45,20 @@ class ConfigVariable
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSection(): ?string
|
public function getSection(): ConfigSectionType
|
||||||
{
|
{
|
||||||
return $this->section;
|
return $this->section;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSection(?string $section): static
|
public function setSection(ConfigSectionType $section): static
|
||||||
{
|
{
|
||||||
$this->section = $section;
|
$this->section = $section;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function __toString(): string
|
||||||
|
{
|
||||||
|
return $this->getKey();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class FareTable
|
|||||||
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
||||||
private ?RoomCategory $roomCategory = null;
|
private ?RoomCategory $roomCategory = null;
|
||||||
|
|
||||||
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
|
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: false)]
|
||||||
private ?\DateTimeInterface $startDate = null;
|
private ?\DateTimeInterface $startDate = null;
|
||||||
|
|
||||||
#[ORM\Column(type : Types::DATETIME_MUTABLE, nullable: true)]
|
#[ORM\Column(type : Types::DATETIME_MUTABLE, nullable: true)]
|
||||||
@@ -125,10 +125,14 @@ class FareTable
|
|||||||
|
|
||||||
public function __toString(): string
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
|
$str = $this->id;
|
||||||
if (!\is_null($this->comment)) {
|
if (!\is_null($this->comment)) {
|
||||||
return $this->comment;
|
$str = $this->comment;
|
||||||
}
|
}
|
||||||
return $this->id;
|
$str . "(" . $this->roomCategory . ")";
|
||||||
|
if (!\is_null($this->roomCategory)) {
|
||||||
|
}
|
||||||
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,7 +164,7 @@ class FareTable
|
|||||||
/**
|
/**
|
||||||
* Obtiene las tarifas que aplican al GuestNumber indicado.
|
* Obtiene las tarifas que aplican al GuestNumber indicado.
|
||||||
* @param int $guestNumber GuestNumber para búsqueda.
|
* @param int $guestNumber GuestNumber para búsqueda.
|
||||||
* @return RoomFare[] Lista de tarifas.
|
* @return Collection<RoomFare> Lista de tarifas.
|
||||||
*/
|
*/
|
||||||
public function getRoomFaresByGuestNumber(int $guestNumber)
|
public function getRoomFaresByGuestNumber(int $guestNumber)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class RoomAvailability
|
|||||||
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
||||||
private ?RoomCategory $roomCategory = null;
|
private ?RoomCategory $roomCategory = null;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column(nullable: false)]
|
||||||
private ?int $numAvailable = null;
|
private ?int $numAvailable = null;
|
||||||
|
|
||||||
public function getDay(): ?\DateTimeInterface
|
public function getDay(): ?\DateTimeInterface
|
||||||
|
|||||||
+38
-38
@@ -22,12 +22,12 @@ class RoomCategory
|
|||||||
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
#[ORM\Column(type: Types::TEXT, nullable: true)]
|
||||||
private ?string $description = null;
|
private ?string $description = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 64, nullable: true)]
|
#[ORM\Column(nullable: false)]
|
||||||
private ?string $bedType = null;
|
|
||||||
|
|
||||||
#[ORM\Column]
|
|
||||||
private ?int $maxGuestNum = null;
|
private ?int $maxGuestNum = null;
|
||||||
|
|
||||||
|
#[ORM\Column(type: Types::SMALLINT, nullable: true)]
|
||||||
|
private ?int $orderHomePage = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection<int, RoomCategoryPhoto>
|
* @var Collection<int, RoomCategoryPhoto>
|
||||||
*/
|
*/
|
||||||
@@ -35,15 +35,15 @@ class RoomCategory
|
|||||||
private Collection $roomCategoryPhotos;
|
private Collection $roomCategoryPhotos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Collection<int, RoomCategoryDetails>
|
* @var Collection<int, RoomCategoryBedType>
|
||||||
*/
|
*/
|
||||||
#[ORM\OneToMany(targetEntity: RoomCategoryDetails::class, mappedBy: 'roomCategory', orphanRemoval: true, cascade: ['persist'])]
|
#[ORM\OneToMany(targetEntity: RoomCategoryBedType::class, mappedBy: 'roomCategory', orphanRemoval: true, cascade: ['persist'])]
|
||||||
private Collection $roomCategoryDetails;
|
private Collection $roomCategoryBedTypes;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->roomCategoryPhotos = new ArrayCollection();
|
$this->roomCategoryPhotos = new ArrayCollection();
|
||||||
$this->roomCategoryDetails = new ArrayCollection();
|
$this->roomCategoryBedTypes = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
public function getId(): ?int
|
||||||
@@ -75,18 +75,6 @@ class RoomCategory
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBedType(): ?string
|
|
||||||
{
|
|
||||||
return $this->bedType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setBedType(?string $bedType): static
|
|
||||||
{
|
|
||||||
$this->bedType = $bedType;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMaxGuestNum(): ?int
|
public function getMaxGuestNum(): ?int
|
||||||
{
|
{
|
||||||
return $this->maxGuestNum;
|
return $this->maxGuestNum;
|
||||||
@@ -99,6 +87,18 @@ class RoomCategory
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOrderHomePage(): ?int
|
||||||
|
{
|
||||||
|
return $this->orderHomePage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setOrderHomePage(?int $orderHomePage): static
|
||||||
|
{
|
||||||
|
$this->orderHomePage = $orderHomePage;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection<int, RoomCategoryPhoto>
|
* @return Collection<int, RoomCategoryPhoto>
|
||||||
*/
|
*/
|
||||||
@@ -129,38 +129,38 @@ class RoomCategory
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function __toString()
|
||||||
* @return Collection<int, RoomCategoryDetails>
|
|
||||||
*/
|
|
||||||
public function getRoomCategoryDetails(): Collection
|
|
||||||
{
|
{
|
||||||
return $this->roomCategoryDetails;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRoomCategoryDetail(RoomCategoryDetails $roomCategoryDetail): static
|
/**
|
||||||
|
* @return Collection<int, RoomCategoryBedType>
|
||||||
|
*/
|
||||||
|
public function getRoomCategoryBedTypes(): Collection
|
||||||
{
|
{
|
||||||
if (!$this->roomCategoryDetails->contains($roomCategoryDetail)) {
|
return $this->roomCategoryBedTypes;
|
||||||
$this->roomCategoryDetails->add($roomCategoryDetail);
|
}
|
||||||
$roomCategoryDetail->setRoomCategory($this);
|
|
||||||
|
public function addRoomCategoryBedType(RoomCategoryBedType $roomCategoryBedType): static
|
||||||
|
{
|
||||||
|
if (!$this->roomCategoryBedTypes->contains($roomCategoryBedType)) {
|
||||||
|
$this->roomCategoryBedTypes->add($roomCategoryBedType);
|
||||||
|
$roomCategoryBedType->setRoomCategory($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeRoomCategoryDetail(RoomCategoryDetails $roomCategoryDetail): static
|
public function removeRoomCategoryBedType(RoomCategoryBedType $roomCategoryBedType): static
|
||||||
{
|
{
|
||||||
if ($this->roomCategoryDetails->removeElement($roomCategoryDetail)) {
|
if ($this->roomCategoryBedTypes->removeElement($roomCategoryBedType)) {
|
||||||
// set the owning side to null (unless already changed)
|
// set the owning side to null (unless already changed)
|
||||||
if ($roomCategoryDetail->getRoomCategory() === $this) {
|
if ($roomCategoryBedType->getRoomCategory() === $this) {
|
||||||
$roomCategoryDetail->setRoomCategory(null);
|
$roomCategoryBedType->setRoomCategory(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString()
|
|
||||||
{
|
|
||||||
return $this->name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Repository\RoomCategoryBedTypeRepository;
|
||||||
|
use Symfony\Component\Serializer\Annotation\Ignore;
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
|
||||||
|
#[ORM\Entity(repositoryClass: RoomCategoryBedTypeRepository::class)]
|
||||||
|
class RoomCategoryBedType
|
||||||
|
{
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\ManyToOne(inversedBy: 'roomCategoryBedTypes')]
|
||||||
|
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
||||||
|
#[Ignore]
|
||||||
|
private ?RoomCategory $roomCategory = null;
|
||||||
|
|
||||||
|
#[ORM\Id]
|
||||||
|
#[ORM\ManyToOne]
|
||||||
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
|
#[Ignore]
|
||||||
|
private ?BedType $bedType = null;
|
||||||
|
|
||||||
|
#[ORM\Column]
|
||||||
|
private ?int $amount = null;
|
||||||
|
|
||||||
|
// public function __construct(RoomCategory $roomCat, BedType $bedType) {
|
||||||
|
// $this->roomCategory = $roomCat;
|
||||||
|
// $this->bedType = $bedType;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function getAmount(): ?int
|
||||||
|
{
|
||||||
|
return $this->amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAmount(int $amount): static
|
||||||
|
{
|
||||||
|
$this->amount = $amount;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRoomCategory(): ?RoomCategory
|
||||||
|
{
|
||||||
|
return $this->roomCategory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRoomCategory(?RoomCategory $roomCategory): static
|
||||||
|
{
|
||||||
|
$this->roomCategory = $roomCategory;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBedType(): ?BedType
|
||||||
|
{
|
||||||
|
return $this->bedType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBedType(?BedType $bedType): static
|
||||||
|
{
|
||||||
|
$this->bedType = $bedType;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBedTypeName(): string {
|
||||||
|
return $this->getBedType()->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBedTypeIcon(): string {
|
||||||
|
return $this->getBedType()->getIconUrl();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use App\Repository\RoomCategoryDetailsRepository;
|
|
||||||
use Symfony\Component\Serializer\Annotation\Ignore;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: RoomCategoryDetailsRepository::class)]
|
|
||||||
class RoomCategoryDetails
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $detailsSection = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $detailValue = null;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'roomCategoryDetails')]
|
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
|
||||||
#[Ignore]
|
|
||||||
private ?RoomCategory $roomCategory = null;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDetailsSection(): ?string
|
|
||||||
{
|
|
||||||
return $this->detailsSection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDetailsSection(string $detailsSection): static
|
|
||||||
{
|
|
||||||
$this->detailsSection = $detailsSection;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDetailValue(): ?string
|
|
||||||
{
|
|
||||||
return $this->detailValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setDetailValue(string $detailValue): static
|
|
||||||
{
|
|
||||||
$this->detailValue = $detailValue;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Ignore]
|
|
||||||
public function getRoomCategory(): ?RoomCategory
|
|
||||||
{
|
|
||||||
return $this->roomCategory;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Ignore]
|
|
||||||
public function setRoomCategory(?RoomCategory $roomCategory): static
|
|
||||||
{
|
|
||||||
$this->roomCategory = $roomCategory;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -12,16 +12,17 @@ class RoomCategoryPhoto
|
|||||||
#[ORM\Id]
|
#[ORM\Id]
|
||||||
#[ORM\GeneratedValue]
|
#[ORM\GeneratedValue]
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
|
#[Ignore]
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
#[ORM\Column(length: 255, nullable: false)]
|
||||||
private ?string $path = null;
|
private ?string $path = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 255, nullable: true)]
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
private ?string $altText = null;
|
private ?string $altText = null;
|
||||||
|
|
||||||
#[ORM\Column(length: 30)]
|
#[ORM\Column(nullable: true)]
|
||||||
private ?string $kind = null;
|
private ?int $photoOrder = null;
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'roomCategoryPhotos')]
|
#[ORM\ManyToOne(inversedBy: 'roomCategoryPhotos')]
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
@@ -57,25 +58,23 @@ class RoomCategoryPhoto
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getKind(): ?string
|
public function getPhotoOrder(): ?int
|
||||||
{
|
{
|
||||||
return $this->kind;
|
return $this->photoOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setKind(string $kind): static
|
public function setPhotoOrder(?int $photoOrder): static
|
||||||
{
|
{
|
||||||
$this->kind = $kind;
|
$this->photoOrder = $photoOrder;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Ignore]
|
|
||||||
public function getRoomCategory(): ?RoomCategory
|
public function getRoomCategory(): ?RoomCategory
|
||||||
{
|
{
|
||||||
return $this->roomCategory;
|
return $this->roomCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Ignore]
|
|
||||||
public function setRoomCategory(?RoomCategory $roomCategory): static
|
public function setRoomCategory(?RoomCategory $roomCategory): static
|
||||||
{
|
{
|
||||||
$this->roomCategory = $roomCategory;
|
$this->roomCategory = $roomCategory;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class RoomFare
|
|||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
#[ORM\ManyToOne(inversedBy: 'roomFares')]
|
#[ORM\ManyToOne(inversedBy: 'roomFares')]
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
|
||||||
private ?FareTable $fareTable = null;
|
private ?FareTable $fareTable = null;
|
||||||
|
|
||||||
#[ORM\Column]
|
#[ORM\Column]
|
||||||
|
|||||||
+3
-2
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
|
use App\Enum\UserRoleEnum;
|
||||||
use App\Repository\UserRepository;
|
use App\Repository\UserRepository;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
||||||
@@ -73,7 +74,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||||||
{
|
{
|
||||||
$roles = $this->roles;
|
$roles = $this->roles;
|
||||||
// guarantee every user at least has ROLE_USER
|
// guarantee every user at least has ROLE_USER
|
||||||
$roles[] = 'ROLE_USER';
|
$roles[] = UserRoleEnum::ROLE_USER->value;
|
||||||
|
|
||||||
return array_unique($roles);
|
return array_unique($roles);
|
||||||
}
|
}
|
||||||
@@ -122,6 +123,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
|||||||
public function eraseCredentials(): void
|
public function eraseCredentials(): void
|
||||||
{
|
{
|
||||||
// If you store any temporary, sensitive data on the user, clear it here
|
// If you store any temporary, sensitive data on the user, clear it here
|
||||||
// $this->plainPassword = null;
|
$this->plainPassword = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enum;
|
||||||
|
|
||||||
|
enum ConfigSectionType: string {
|
||||||
|
case General = 'GENERAL';
|
||||||
|
case Internal = 'INTERNAL';
|
||||||
|
case Company = 'COMPANY';
|
||||||
|
case Backend = 'BACK';
|
||||||
|
case Frontend = 'FRONT';
|
||||||
|
case Test = 'TEST';
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enum;
|
||||||
|
|
||||||
|
|
||||||
|
enum UserRoleEnum: string
|
||||||
|
{
|
||||||
|
case ROLE_USER = 'ROLE_USER';
|
||||||
|
case ROLE_ADMIN = 'ROLE_ADMIN';
|
||||||
|
case ROLE_SUPERADMIN = 'ROLE_SUPERADMIN';
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\EventSubscriber;
|
||||||
|
|
||||||
|
use App\ApiErrorException;
|
||||||
|
use App\DTO\ApiErrorMessage;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
|
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||||
|
use Symfony\Component\HttpKernel\KernelEvents;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||||
|
use Symfony\Component\Validator\Exception\ValidationFailedException;
|
||||||
|
|
||||||
|
class ApiExceptionSubscriber implements EventSubscriberInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
private LoggerInterface $logger,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function onKernelException(ExceptionEvent $event): void
|
||||||
|
{
|
||||||
|
$e = $event->getThrowable();
|
||||||
|
if ($e instanceof ApiErrorException) {
|
||||||
|
$apiErrorMsg = $e->getApiErrorMsg();
|
||||||
|
} else {
|
||||||
|
$statusCode = $e instanceof HttpExceptionInterface ? $e->getStatusCode() : 500;
|
||||||
|
$apiErrorMsg = new ApiErrorMessage($statusCode);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If it's an HttpException message (e.g. for 404, 403),
|
||||||
|
* we'll say as a rule that the exception message is safe
|
||||||
|
* for the client. Otherwise, it could be some sensitive
|
||||||
|
* low-level exception, which should *not* be exposed
|
||||||
|
*/
|
||||||
|
if ($e instanceof HttpExceptionInterface) {
|
||||||
|
//Check if it's a Validation error.
|
||||||
|
// When using MapRequestPayload() ValidationErrors throw HttpExceptions.
|
||||||
|
$prev = $e->getPrevious();
|
||||||
|
if ($prev instanceof ValidationFailedException) {
|
||||||
|
//Get validation error details.
|
||||||
|
$errorList = [];
|
||||||
|
$violationList = $prev->getViolations();
|
||||||
|
foreach ($violationList as $violation) {
|
||||||
|
$errorList[] = [
|
||||||
|
'field' => $violation->getPropertyPath(),
|
||||||
|
'message' => $violation->getMessage(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
$apiErrorMsg->setExtraData('detail', "Validation Error. See errorList for details");
|
||||||
|
$apiErrorMsg->setExtraData('errorList', $errorList);
|
||||||
|
} else {
|
||||||
|
//Get exception error message.
|
||||||
|
$apiErrorMsg->setExtraData('detail', $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Send error to logs.
|
||||||
|
$exceptionError = [
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'file' => $e->getFile(),
|
||||||
|
'line' => $e->getLine(),
|
||||||
|
'trace' => $e->getTrace()
|
||||||
|
];
|
||||||
|
$errorContext = array_merge($apiErrorMsg->toArray(), $exceptionError);
|
||||||
|
$this->logger->error("API ERROR Exception:", $errorContext);
|
||||||
|
|
||||||
|
//Send error to client.
|
||||||
|
$response = new JsonResponse(
|
||||||
|
$apiErrorMsg->toArray(),
|
||||||
|
$apiErrorMsg->getStatusCode()
|
||||||
|
);
|
||||||
|
$response->headers->set('Content-Type', 'application/problem+json');
|
||||||
|
|
||||||
|
$event->setResponse($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getSubscribedEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
KernelEvents::EXCEPTION => 'onKernelException',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Form;
|
||||||
|
|
||||||
|
use App\DTO\AppSetupConfig;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
class AppSetupFormType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$builder->add('adminUser', TextType::class);
|
||||||
|
$builder->add('adminPass', PasswordType::class);
|
||||||
|
$builder->add('genExampleData', CheckboxType::class, [
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('setup', SubmitType::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => AppSetupConfig::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Form;
|
||||||
|
|
||||||
|
use App\DTO\ExampleDataConfig;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
class ExampleDataFormType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$builder->add('startDate', DateType::class);
|
||||||
|
$builder->add('endDate', DateType::class);
|
||||||
|
|
||||||
|
$builder->add('genRoomCategories', CheckboxType::class, [
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
$builder->add('genFaretables', CheckboxType::class, [
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
$builder->add('genAvailability', CheckboxType::class, [
|
||||||
|
'required' => false,
|
||||||
|
]);
|
||||||
|
$builder->add('genMode', ChoiceType::class, [
|
||||||
|
'choices' => [
|
||||||
|
'Random' => ExampleDataConfig::GENMODE_RANDOM,
|
||||||
|
'Example' => ExampleDataConfig::GENMODE_EXAMPLE
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$builder->add('Generate', SubmitType::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => ExampleDataConfig::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Form;
|
||||||
|
|
||||||
|
use App\Entity\BedType;
|
||||||
|
use App\Entity\RoomCategory;
|
||||||
|
use App\Entity\RoomCategoryBedType;
|
||||||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
|
use Symfony\Component\Form\AbstractType;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||||
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
|
class RoomCategoryBedTypeFormType extends AbstractType
|
||||||
|
{
|
||||||
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||||
|
{
|
||||||
|
$selectRoomCategory = $options['selectRoomCategory'];
|
||||||
|
|
||||||
|
if($selectRoomCategory) {
|
||||||
|
$builder->add('roomCategory', EntityType::class, [
|
||||||
|
'class' => RoomCategory::class,
|
||||||
|
'choice_label' => 'name'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder->add('bedType', EntityType::class, [
|
||||||
|
'class' => BedType::class,
|
||||||
|
'choice_label' => 'name',
|
||||||
|
]);
|
||||||
|
$builder->add('amount', IntegerType::class);
|
||||||
|
$builder->add('save', SubmitType::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
|
{
|
||||||
|
$resolver->setDefaults([
|
||||||
|
'data_class' => RoomCategoryBedType::class,
|
||||||
|
'selectRoomCategory' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$resolver->setAllowedTypes('selectRoomCategory', 'bool');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\BedType;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<BedType>
|
||||||
|
*
|
||||||
|
* @method BedType|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method BedType|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method BedType[] findAll()
|
||||||
|
* @method BedType[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
class BedTypeRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, BedType::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @return BedType[] Returns an array of BedType objects
|
||||||
|
// */
|
||||||
|
// public function findByExampleField($value): array
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('b')
|
||||||
|
// ->andWhere('b.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->orderBy('b.id', 'ASC')
|
||||||
|
// ->setMaxResults(10)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?BedType
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('b')
|
||||||
|
// ->andWhere('b.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getOneOrNullResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace App\Repository;
|
|||||||
|
|
||||||
use App\Entity\RoomAvailability;
|
use App\Entity\RoomAvailability;
|
||||||
use App\Entity\RoomCategory;
|
use App\Entity\RoomCategory;
|
||||||
|
use DateInterval;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
@@ -129,14 +130,16 @@ class RoomAvailabilityRepository extends ServiceEntityRepository
|
|||||||
/**
|
/**
|
||||||
* For a given RoomCategory, sets its availability for all days on a period with the given amount.
|
* For a given RoomCategory, sets its availability for all days on a period with the given amount.
|
||||||
*/
|
*/
|
||||||
public function bulkEditRoomAvailabilityForCategoryOnPeriod(RoomCategory $roomCategory, \DateTimeInterface $startDate, \DateTimeInterface $endDate, int $amount): void
|
public function bulkEditRoomAvailabilityForCategoryOnPeriod(RoomCategory $roomCategory, \DateTimeInterface $startDate, \DateTimeInterface $endDate, int $amount, bool $useTransactions = true): void
|
||||||
{
|
{
|
||||||
$strStartDate = $startDate->format('Y-m-d');
|
$strStartDate = $startDate->format('Y-m-d');
|
||||||
$strEndDate = $endDate->format('Y-m-d');
|
$strEndDate = $endDate->format('Y-m-d');
|
||||||
$roomCatId = $roomCategory->getId();
|
$roomCatId = $roomCategory->getId();
|
||||||
|
|
||||||
$entityManager = $this->getEntityManager();
|
$entityManager = $this->getEntityManager();
|
||||||
$entityManager->beginTransaction();
|
if ($useTransactions) {
|
||||||
|
$entityManager->beginTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@@ -144,7 +147,7 @@ class RoomAvailabilityRepository extends ServiceEntityRepository
|
|||||||
$this->createQueryBuilder('ra')
|
$this->createQueryBuilder('ra')
|
||||||
->delete()
|
->delete()
|
||||||
->andWhere('ra.day >= :startDate')
|
->andWhere('ra.day >= :startDate')
|
||||||
->andWhere('ra.day < :endDate')
|
->andWhere('ra.day <= :endDate')
|
||||||
->andWhere('ra.roomCategory = :roomCategory')
|
->andWhere('ra.roomCategory = :roomCategory')
|
||||||
->setParameter('roomCategory', $roomCatId)
|
->setParameter('roomCategory', $roomCatId)
|
||||||
->setParameter('startDate', $strStartDate)
|
->setParameter('startDate', $strStartDate)
|
||||||
@@ -154,8 +157,10 @@ class RoomAvailabilityRepository extends ServiceEntityRepository
|
|||||||
|
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
|
|
||||||
|
// Include end date.
|
||||||
|
$endDateIncluded = date_add($endDate, new DateInterval("P1D"));
|
||||||
//For each day, create item and persist it.
|
//For each day, create item and persist it.
|
||||||
$daterange = new \DatePeriod($startDate, new \DateInterval('P1D'), $endDate);
|
$daterange = new \DatePeriod($startDate, new \DateInterval('P1D'), $endDateIncluded);
|
||||||
foreach ($daterange as $date) {
|
foreach ($daterange as $date) {
|
||||||
$item = new RoomAvailability();
|
$item = new RoomAvailability();
|
||||||
$item->setRoomCategory($roomCategory);
|
$item->setRoomCategory($roomCategory);
|
||||||
@@ -166,12 +171,15 @@ class RoomAvailabilityRepository extends ServiceEntityRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
$entityManager->commit();
|
|
||||||
|
|
||||||
|
if ($useTransactions) {
|
||||||
|
$entityManager->commit();
|
||||||
|
}
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
$entityManager->rollback();
|
if ($useTransactions) {
|
||||||
|
$entityManager->rollback();
|
||||||
|
}
|
||||||
throw $th;
|
throw $th;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Repository;
|
||||||
|
|
||||||
|
use App\Entity\RoomCategoryBedType;
|
||||||
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends ServiceEntityRepository<RoomCategoryBedType>
|
||||||
|
*
|
||||||
|
* @method RoomCategoryBedType|null find($id, $lockMode = null, $lockVersion = null)
|
||||||
|
* @method RoomCategoryBedType|null findOneBy(array $criteria, array $orderBy = null)
|
||||||
|
* @method RoomCategoryBedType[] findAll()
|
||||||
|
* @method RoomCategoryBedType[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||||
|
*/
|
||||||
|
class RoomCategoryBedTypeRepository extends ServiceEntityRepository
|
||||||
|
{
|
||||||
|
public function __construct(ManagerRegistry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry, RoomCategoryBedType::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return RoomCategoryBedType[] Returns an array of RoomCategoryBedType objects
|
||||||
|
*/
|
||||||
|
public function findByRoomCategory(string $categoryId): array
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('r')
|
||||||
|
->andWhere('r.roomCategory = :catId')
|
||||||
|
->setParameter('catId', $categoryId)
|
||||||
|
->getQuery()
|
||||||
|
->getResult()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function findOneBySomeField($value): ?RoomCategoryBedType
|
||||||
|
// {
|
||||||
|
// return $this->createQueryBuilder('r')
|
||||||
|
// ->andWhere('r.exampleField = :val')
|
||||||
|
// ->setParameter('val', $value)
|
||||||
|
// ->getQuery()
|
||||||
|
// ->getOneOrNullResult()
|
||||||
|
// ;
|
||||||
|
// }
|
||||||
|
}
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Repository;
|
|
||||||
|
|
||||||
use App\Entity\RoomCategoryDetails;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @extends ServiceEntityRepository<RoomCategoryDetails>
|
|
||||||
*
|
|
||||||
* @method RoomCategoryDetails|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method RoomCategoryDetails|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method RoomCategoryDetails[] findAll()
|
|
||||||
* @method RoomCategoryDetails[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class RoomCategoryDetailsRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, RoomCategoryDetails::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @return RoomCategoryDetails[] Returns an array of RoomCategoryDetails objects
|
|
||||||
// */
|
|
||||||
// public function findByExampleField($value): array
|
|
||||||
// {
|
|
||||||
// return $this->createQueryBuilder('r')
|
|
||||||
// ->andWhere('r.exampleField = :val')
|
|
||||||
// ->setParameter('val', $value)
|
|
||||||
// ->orderBy('r.id', 'ASC')
|
|
||||||
// ->setMaxResults(10)
|
|
||||||
// ->getQuery()
|
|
||||||
// ->getResult()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public function findOneBySomeField($value): ?RoomCategoryDetails
|
|
||||||
// {
|
|
||||||
// return $this->createQueryBuilder('r')
|
|
||||||
// ->andWhere('r.exampleField = :val')
|
|
||||||
// ->setParameter('val', $value)
|
|
||||||
// ->getQuery()
|
|
||||||
// ->getOneOrNullResult()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Request;
|
||||||
|
|
||||||
|
use App\Entity\BookingCustomer;
|
||||||
|
use DateTimeInterface;
|
||||||
|
use OpenApi\Attributes as OA;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
class BookingCreateRequest
|
||||||
|
{
|
||||||
|
#[OA\Property(description: 'Booking Arrival date')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
#[Assert\GreaterThanOrEqual(value: 'today')]
|
||||||
|
public DateTimeInterface $arrivalDate;
|
||||||
|
|
||||||
|
#[OA\Property(description: 'Booking departure date')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
public DateTimeInterface $departureDate;
|
||||||
|
|
||||||
|
#[OA\Property(
|
||||||
|
description: 'Booking customer details',
|
||||||
|
)]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
#[Assert\Valid]
|
||||||
|
public BookingCustomer $customerDetails;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var BookingCreateRoomItem[]
|
||||||
|
*/
|
||||||
|
#[OA\Property(
|
||||||
|
description: 'Rooms to book',
|
||||||
|
)]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
#[Assert\Valid]
|
||||||
|
public array $rooms;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Request;
|
||||||
|
|
||||||
|
use OpenApi\Attributes as OA;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
class BookingCreateRoomItem
|
||||||
|
{
|
||||||
|
#[OA\Property(description: 'Room category ID')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
public int $roomCategory;
|
||||||
|
|
||||||
|
#[OA\Property(description: 'Guest number for the room')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
#[Assert\GreaterThan(value: 0)]
|
||||||
|
public int $guestNumber;
|
||||||
|
|
||||||
|
#[OA\Property(description: 'Room amount')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
#[Assert\GreaterThan(value: 0)]
|
||||||
|
public int $amount;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Request;
|
||||||
|
|
||||||
|
use OpenApi\Attributes as OA;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
class BookingDetailsRequest
|
||||||
|
{
|
||||||
|
#[OA\Property(description: 'Booking reference number')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
public string $refNumber;
|
||||||
|
|
||||||
|
#[OA\Property(maxLength: 255, description: 'Email associated to the booking')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
#[Assert\Email]
|
||||||
|
public string $email;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Request;
|
||||||
|
|
||||||
|
use DateTimeInterface;
|
||||||
|
use OpenApi\Attributes as OA;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
class SearchAvailabilityPeriodRequest
|
||||||
|
{
|
||||||
|
#[OA\Property(description: 'Period start date')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
public DateTimeInterface $startDate;
|
||||||
|
|
||||||
|
#[OA\Property(description: 'Period end date')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
public DateTimeInterface $endDate;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Request;
|
||||||
|
|
||||||
|
use DateTimeInterface;
|
||||||
|
use OpenApi\Attributes as OA;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
class SearchPricesForCategoryRequest
|
||||||
|
{
|
||||||
|
#[OA\Property(description: 'Room category ID')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
public int $roomCategory;
|
||||||
|
|
||||||
|
#[OA\Property(description: 'Period start date')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
public DateTimeInterface $startDate;
|
||||||
|
|
||||||
|
#[OA\Property(description: 'Period end date')]
|
||||||
|
#[Assert\NotBlank]
|
||||||
|
public DateTimeInterface $endDate;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Response;
|
||||||
|
|
||||||
|
use OpenApi\Attributes as OA;
|
||||||
|
|
||||||
|
class BookingCreateResponse
|
||||||
|
{
|
||||||
|
#[OA\Property(description: 'Booking reference number')]
|
||||||
|
public string $refNumber;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Response;
|
||||||
|
|
||||||
|
use OpenApi\Attributes as OA;
|
||||||
|
|
||||||
|
class SearchAvailabilityResponse
|
||||||
|
{
|
||||||
|
#[OA\Property(description: 'Room category ID')]
|
||||||
|
public string $roomCategory;
|
||||||
|
|
||||||
|
#[OA\Property(description: 'Number of available rooms')]
|
||||||
|
public int $availability;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Response;
|
||||||
|
|
||||||
|
use OpenApi\Attributes as OA;
|
||||||
|
|
||||||
|
class SearchPricesForCategoryResponse
|
||||||
|
{
|
||||||
|
#[OA\Property(description: 'Number of guests')]
|
||||||
|
public int $guestNumber;
|
||||||
|
|
||||||
|
#[OA\Property(description: 'room price')]
|
||||||
|
public int $price;
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Service;
|
||||||
|
|
||||||
|
use App\DTO\AppSetupConfig;
|
||||||
|
use App\Entity\ConfigVariable;
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Enum\ConfigSectionType;
|
||||||
|
use App\Enum\UserRoleEnum;
|
||||||
|
use App\Repository\ConfigVariableRepository;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
use Symfony\Bundle\SecurityBundle\Security;
|
||||||
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service for setup proccess.
|
||||||
|
*/
|
||||||
|
class AppSetupService
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
private LoggerInterface $logger,
|
||||||
|
private EntityManagerInterface $entityManager,
|
||||||
|
private ConfigVariableRepository $repoVariables,
|
||||||
|
private UserPasswordHasherInterface $passwordHasher,
|
||||||
|
private Security $security
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function InitialSetup(AppSetupConfig $configData): bool
|
||||||
|
{
|
||||||
|
$this->entityManager->beginTransaction();
|
||||||
|
$user = new User();
|
||||||
|
|
||||||
|
try {
|
||||||
|
//Create system variables.
|
||||||
|
$this->logger->info("SomniaRooms Setup - Creating system variables...");
|
||||||
|
|
||||||
|
$var_setup = $this->repoVariables->find("SETUP_STATUS");
|
||||||
|
if (!$var_setup) {
|
||||||
|
$var_setup = new ConfigVariable();
|
||||||
|
$var_setup->setKey("SETUP_STATUS");
|
||||||
|
}
|
||||||
|
$var_setup->setValue("1");
|
||||||
|
$var_setup->setSection(ConfigSectionType::Internal);
|
||||||
|
$this->entityManager->persist($var_setup);
|
||||||
|
|
||||||
|
|
||||||
|
//Create user Admin.
|
||||||
|
$this->logger->info("SomniaRooms Setup - Adding super-admin user...");
|
||||||
|
$user->setUsername($configData->getAdminUser());
|
||||||
|
$user->setRoles([UserRoleEnum::ROLE_USER->value, UserRoleEnum::ROLE_ADMIN->value, UserRoleEnum::ROLE_SUPERADMIN->value]);
|
||||||
|
$plaintextPassword = $configData->getAdminPass();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// hash the password (based on the security.yaml config for the $user class)
|
||||||
|
$hashedPassword = $this->passwordHasher->hashPassword(
|
||||||
|
$user,
|
||||||
|
$plaintextPassword
|
||||||
|
);
|
||||||
|
$user->setPassword($hashedPassword);
|
||||||
|
|
||||||
|
$this->entityManager->persist($user);
|
||||||
|
$this->entityManager->flush();
|
||||||
|
$this->entityManager->commit();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
$this->entityManager->rollback();
|
||||||
|
throw $th;
|
||||||
|
}
|
||||||
|
|
||||||
|
//If init was sucessfull, log admin user.
|
||||||
|
$this->security->login($user);
|
||||||
|
|
||||||
|
$this->logger->info("SomniaRooms Setup completed!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Service;
|
||||||
|
|
||||||
|
use App\Entity\ConfigVariable;
|
||||||
|
use App\Repository\ConfigVariableRepository;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service to manage config variables.
|
||||||
|
*/
|
||||||
|
class ConfigVariableService
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
private ConfigVariableRepository $repoVariables
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function getVariable(string $key) {
|
||||||
|
$var = $this->repoVariables->findVariableByKey($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and init all variables.
|
||||||
|
* To be used during Setup process.
|
||||||
|
*/
|
||||||
|
public function InitVariablesOnSetup(): void {
|
||||||
|
|
||||||
|
$entityManager = $this->repoVariables->getEntityManager();
|
||||||
|
$entityManager->beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (\Throwable $th) {
|
||||||
|
$entityManager->rollback();
|
||||||
|
throw $th;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function AddConfigVariable(string $key, string $value, string $section): void {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Service;
|
||||||
|
|
||||||
|
use App\DTO\AppSetupConfig;
|
||||||
|
use App\DTO\ExampleDataConfig;
|
||||||
|
use App\Entity\ConfigVariable;
|
||||||
|
use App\Entity\FareTable;
|
||||||
|
use App\Entity\RoomCategory;
|
||||||
|
use App\Entity\RoomFare;
|
||||||
|
use App\Entity\User;
|
||||||
|
use App\Enum\ConfigSectionType;
|
||||||
|
use App\Enum\UserRoleEnum;
|
||||||
|
use App\Repository\ConfigVariableRepository;
|
||||||
|
use App\Repository\FareTableRepository;
|
||||||
|
use App\Repository\RoomAvailabilityRepository;
|
||||||
|
use App\Repository\RoomCategoryRepository;
|
||||||
|
use App\Repository\RoomFareRepository;
|
||||||
|
use DateTime;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service for setup proccess.
|
||||||
|
*/
|
||||||
|
class ExampleDataService
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
private LoggerInterface $logger,
|
||||||
|
private EntityManagerInterface $entityManager,
|
||||||
|
private RoomCategoryRepository $roomCategoryRepository,
|
||||||
|
private RoomAvailabilityRepository $roomAvailabilityRepository,
|
||||||
|
private FareTableRepository $fareTableRepository,
|
||||||
|
private RoomFareRepository $roomFareRepository,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function AddExampleData(ExampleDataConfig $config): string
|
||||||
|
{
|
||||||
|
$genMode = $config->getGenMode();
|
||||||
|
if ($genMode == ExampleDataConfig::GENMODE_EXAMPLE) {
|
||||||
|
return "'Example' generation mode is not supported yet!";
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entityManager->beginTransaction();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($config->getGenRoomCategories()) {
|
||||||
|
$this->GenerateRoomCategories();
|
||||||
|
}
|
||||||
|
if ($config->getGenAvailability()) {
|
||||||
|
$this->GenerateAvailability($config);
|
||||||
|
}
|
||||||
|
if ($config->getGenFaretables()) {
|
||||||
|
$this->GenerateFares($config);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entityManager->flush();
|
||||||
|
$this->entityManager->commit();
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
$this->entityManager->rollback();
|
||||||
|
throw $th;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
|
||||||
|
private function GenerateRoomCategories(): bool
|
||||||
|
{
|
||||||
|
//TODOME.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function GenerateAvailability(ExampleDataConfig $config): bool
|
||||||
|
{
|
||||||
|
$roomCategoryList = $this->roomCategoryRepository->findAll();
|
||||||
|
foreach ($roomCategoryList as $room) {
|
||||||
|
//TODOME: Make amounts configurable.
|
||||||
|
$amount = random_int(0, 7);
|
||||||
|
$this->roomAvailabilityRepository->bulkEditRoomAvailabilityForCategoryOnPeriod(
|
||||||
|
$room,
|
||||||
|
$config->getStartDate(),
|
||||||
|
$config->getEndDate(),
|
||||||
|
$amount,
|
||||||
|
useTransactions: false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function GenerateFares(ExampleDataConfig $config): bool
|
||||||
|
{
|
||||||
|
$generationTime = new DateTime();
|
||||||
|
$strGenTime = $generationTime->format('d-m-Y H:i:s');
|
||||||
|
|
||||||
|
$roomCategoryList = $this->roomCategoryRepository->findAll();
|
||||||
|
foreach ($roomCategoryList as $room) {
|
||||||
|
$list = $this->fareTableRepository->findFareTable($room->getId(), $config->getStartDate(), $config->getEndDate());
|
||||||
|
if (count($list) > 0) {
|
||||||
|
//TODOME: Log info.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$fareTable = new FareTable();
|
||||||
|
$fareTable->setStartDate($config->getStartDate());
|
||||||
|
$fareTable->setEndDate($config->getEndDate());
|
||||||
|
$fareTable->setRoomCategory($room);
|
||||||
|
$fareTable->setComment("Autogenerated " . $strGenTime);
|
||||||
|
|
||||||
|
$this->entityManager->persist($fareTable);
|
||||||
|
|
||||||
|
for ($i = 1; $i < $room->getMaxGuestNum(); $i++) {
|
||||||
|
$roomFare = new RoomFare();
|
||||||
|
$roomFare->setGuestNumber($i);
|
||||||
|
$roomFare->setFareTable($fareTable);
|
||||||
|
|
||||||
|
//TODOME: Make amounts configurable.
|
||||||
|
// Random price per person.
|
||||||
|
$amount = random_int(10, 25) * $i * 100;
|
||||||
|
$roomFare->setFareAmount($amount);
|
||||||
|
|
||||||
|
$this->entityManager->persist($roomFare);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Service;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||||
|
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||||
|
use Symfony\Component\String\Slugger\SluggerInterface;
|
||||||
|
|
||||||
|
class FileUploaderService
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private string $targetDirectory,
|
||||||
|
private SluggerInterface $slugger,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function upload(UploadedFile $file): string
|
||||||
|
{
|
||||||
|
$originalFilename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
|
||||||
|
$safeFilename = $this->slugger->slug($originalFilename);
|
||||||
|
$fileName = $safeFilename . '-' . uniqid() . '.' . $file->guessExtension();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$file->move($this->getTargetDirectory(), $fileName);
|
||||||
|
} catch (FileException $e) {
|
||||||
|
// ... handle exception if something happens during file upload
|
||||||
|
}
|
||||||
|
|
||||||
|
return $fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteFile(string $filepath): bool
|
||||||
|
{
|
||||||
|
if (!$filepath || !is_file($filepath)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$deleted = unlink($filepath);
|
||||||
|
|
||||||
|
return $deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTargetDirectory(): string
|
||||||
|
{
|
||||||
|
return $this->targetDirectory;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -127,7 +127,7 @@ class PricesService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Calcula el precio a aplicar según las condiciones de las tarifas.
|
* Calcula el precio a aplicar según las condiciones de las tarifas.
|
||||||
* @param RoomFare[] $roomFareList Lista con las posibles tarifas.
|
* @param Collection<RoomFare> $roomFareList Lista con las posibles tarifas.
|
||||||
* @param DateTimeInterface $fareCondDate Fecha utilizada para las condiciones.
|
* @param DateTimeInterface $fareCondDate Fecha utilizada para las condiciones.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -35,6 +35,19 @@
|
|||||||
"ref": "b131e6cbfe1b898a508987851963fff485986285"
|
"ref": "b131e6cbfe1b898a508987851963fff485986285"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"nelmio/api-doc-bundle": {
|
||||||
|
"version": "4.30",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes-contrib",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "3.0",
|
||||||
|
"ref": "c8e0c38e1a280ab9e37587a8fa32b251d5bc1c94"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"./config/packages/nelmio_api_doc.yaml",
|
||||||
|
"./config/routes/nelmio_api_doc.yaml"
|
||||||
|
]
|
||||||
|
},
|
||||||
"nelmio/cors-bundle": {
|
"nelmio/cors-bundle": {
|
||||||
"version": "2.4",
|
"version": "2.4",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
@@ -47,6 +60,21 @@
|
|||||||
"./config/packages/nelmio_cors.yaml"
|
"./config/packages/nelmio_cors.yaml"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"symfony/asset-mapper": {
|
||||||
|
"version": "7.0",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "6.4",
|
||||||
|
"ref": "6c28c471640cc2c6e60812ebcb961c526ef8997f"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"./assets/app.js",
|
||||||
|
"./assets/styles/app.css",
|
||||||
|
"./config/packages/asset_mapper.yaml",
|
||||||
|
"./importmap.php"
|
||||||
|
]
|
||||||
|
},
|
||||||
"symfony/console": {
|
"symfony/console": {
|
||||||
"version": "7.0",
|
"version": "7.0",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
@@ -99,6 +127,18 @@
|
|||||||
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
|
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"symfony/monolog-bundle": {
|
||||||
|
"version": "3.10",
|
||||||
|
"recipe": {
|
||||||
|
"repo": "github.com/symfony/recipes",
|
||||||
|
"branch": "main",
|
||||||
|
"version": "3.7",
|
||||||
|
"ref": "aff23899c4440dd995907613c1dd709b6f59503f"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"./config/packages/monolog.yaml"
|
||||||
|
]
|
||||||
|
},
|
||||||
"symfony/routing": {
|
"symfony/routing": {
|
||||||
"version": "7.0",
|
"version": "7.0",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
@@ -184,5 +224,8 @@
|
|||||||
"./config/packages/web_profiler.yaml",
|
"./config/packages/web_profiler.yaml",
|
||||||
"./config/routes/web_profiler.yaml"
|
"./config/routes/web_profiler.yaml"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"twig/extra-bundle": {
|
||||||
|
"version": "v3.13.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{# templates/admin/adminEdit.html.twig #}
|
||||||
|
{% extends '@EasyAdmin/page/content.html.twig' %}
|
||||||
|
|
||||||
|
{% block content_title ElementType %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
<div>
|
||||||
|
<h3>{{ElementName}}</h3>
|
||||||
|
</div>
|
||||||
|
{{ form(form) }}
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
{# templates/admin/photo_manager/index.html.twig #}
|
||||||
|
{% extends '@EasyAdmin/page/content.html.twig' %}
|
||||||
|
|
||||||
|
{% block content_title 'Photo Manager' %}
|
||||||
|
{% block main %}
|
||||||
|
|
||||||
|
<a class="btn btn-primary m-3" href="{{ ea_url().setRoute('admin_photos_upload') }}">
|
||||||
|
Add new
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div style="display: flex; flex-direction: row; flex-wrap: wrap; gap: 18px;">
|
||||||
|
{% for photo in photoList %}
|
||||||
|
<div class="card text-center" style="width: 40%;">
|
||||||
|
<p>{{photo.filename}}</p>
|
||||||
|
<img src="{{ asset(photo.url) }}" style="max-width: 80%;"/>
|
||||||
|
<br>
|
||||||
|
<a class="btn btn-outline-primary m-2">
|
||||||
|
<i class="fas fa-clipboard"> Copy!</i>
|
||||||
|
</a>
|
||||||
|
<a class="btn btn-primary m-2 mt-1" href="{{ ea_url().setRoute('admin_photos_remove', { filename: photo.filename }) }}">
|
||||||
|
Delete
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
{# templates/admin/room_category_bed_type_admin/category_view.html.twig #}
|
||||||
|
{% extends '@EasyAdmin/page/content.html.twig' %}
|
||||||
|
|
||||||
|
{% block content_title 'Room Availability' %}
|
||||||
|
{% block main %}
|
||||||
|
<div>
|
||||||
|
<h3>{{categoryData.name}}</h3>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<a href="{{ ea_url().setRoute('admin_roomCategoryBedType_category_create', { categoryId: categoryData.id }) }}">
|
||||||
|
Add BedType
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<table class="datagrid">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>BedType</td>
|
||||||
|
<td>Amount</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for bedType in bedTypeList %}
|
||||||
|
<tr>
|
||||||
|
<td>{{bedType.bedType}}</td>
|
||||||
|
<td>{{bedType.amount}}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ ea_url().setRoute('admin_roomCategoryBedType_category_update', { bedTypeId: bedType.bedType.id, categoryId: bedType.roomCategory.id }) }}">
|
||||||
|
Edit
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ ea_url().setRoute('admin_roomCategoryBedType_category_remove', { bedTypeId: bedType.bedType.id, categoryId: bedType.roomCategory.id }) }}">
|
||||||
|
Remove
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{# templates/admin/room_category_bed_type_admin/index.html.twig #}
|
||||||
|
{% extends '@EasyAdmin/page/content.html.twig' %}
|
||||||
|
|
||||||
|
{% block content_title 'Category Bed Type' %}
|
||||||
|
{% block main %}
|
||||||
|
<table class="datagrid">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>ID</td>
|
||||||
|
<td>RoomCategory</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for category in roomCategoryList %}
|
||||||
|
<tr>
|
||||||
|
<td>{{category.id}}</td>
|
||||||
|
<td>{{category.name}}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{ ea_url().setRoute('admin_roomCategoryBedType_category', { categoryId: category.id }) }}">
|
||||||
|
View Details
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
||||||
@@ -1,6 +1,13 @@
|
|||||||
{# templates/admin/somniaDashboard.html.html.twig #}
|
{# templates/admin/somniaDashboard.html.html.twig #}
|
||||||
{% extends '@EasyAdmin/layout.html.twig' %}
|
{% extends '@EasyAdmin/layout.html.twig' %}
|
||||||
|
|
||||||
|
{% block javascripts %}
|
||||||
|
{% block importmap %}
|
||||||
|
{{ importmap('app') }}
|
||||||
|
{% endblock %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
{# ... #}
|
{# ... #}
|
||||||
{% endblock main %}
|
{% endblock main %}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Example Data{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div class="container">
|
||||||
|
<h1>SomniaRooms - Example data!</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Add example data to your SomniaRooms.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{{ form_start(form) }}
|
||||||
|
|
||||||
|
{% if isFormInvalid %}
|
||||||
|
<div class="msg-container msg-error">
|
||||||
|
{{ form_errors(form) }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-section">
|
||||||
|
<h2>Room Categories</h2>
|
||||||
|
{% if hasRoomCategories %}
|
||||||
|
<div class="msg-container msg-warn">
|
||||||
|
<span>Warning: There are already room categories on the DB. More will be added.</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{{ form_row(form.genRoomCategories) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-section">
|
||||||
|
<h2>Fares and availability</h2>
|
||||||
|
{{ form_row(form.genFaretables) }}
|
||||||
|
{{ form_row(form.genAvailability) }}
|
||||||
|
{{ form_row(form.genMode) }}
|
||||||
|
<br>
|
||||||
|
{{ form_row(form.startDate) }}
|
||||||
|
{{ form_row(form.endDate) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
{{ form_rest(form) }}
|
||||||
|
|
||||||
|
{{ form_end(form) }}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Setup!{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<h1>SomniaRooms - Set-Up!</h1>
|
||||||
|
|
||||||
|
{% if isError %}
|
||||||
|
<img src="{{ asset('resources/x.svg') }}" />
|
||||||
|
{% else %}
|
||||||
|
<img src="{{ asset('resources/coffee.svg') }}" />
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
<p>{{message}}</p>
|
||||||
|
{% if linkRoute and linkLabel %}
|
||||||
|
<a href="{{ path(linkRoute) }}">{{linkLabel}}</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Setup!{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<div class="container">
|
||||||
|
<h1>SomniaRooms - Set-Up!</h1>
|
||||||
|
|
||||||
|
Setup your SomniaRooms backend application.
|
||||||
|
{{ form(form) }}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user