diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c0c71a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +config/db_settings.json +config/currency_settings.json \ No newline at end of file diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..1498617 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,14 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.0] - 2023-01-01 + +### Added + +- Initial Release of the Project + +[1.0]: https://github.com/intragart/Shared-Household-Expenses/releases/tag/v1.0 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + 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 GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md index 4e0920d..e234415 100644 --- a/README.md +++ b/README.md @@ -1 +1,80 @@ -# Shared-Household-Expenses \ No newline at end of file +# ![Shared Household Expenses](https://github.com/intragart/Shared-Household-Expenses/raw/master/webapp/www/content/img/logo-light.png) + +![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/intragart/Shared-Household-Expenses?include_prereleases) +![GitHub last commit](https://img.shields.io/github/last-commit/intragart/Shared-Household-Expenses) +![GitHub license](https://img.shields.io/github/license/intragart/Shared-Household-Expenses) + +With this project you can track the household expenses per person. The idea is to achive that each person contributing to the household spends the same amount of money without any need for spreadsheets or shared bank accounts. + +## Table of contents + +- [Installation](#installation) + - [Database](#database) + - [Webserver](#webserver) + - [Configuration](#configuration) +- [License](#license) + +## Installation + +### Database + +The data is stored in a relational database like MariaDB or MySQL. Create a new database called 'shared_household_expenses' by executing the sql scripts in the follwoing order. + +1. database/create_database.sql +1. database/create_tables.sql +1. database/create_views.sql +1. database/create_functions.sql +1. database/create_users.sql + +Please make sure use proper passwords when executing 'database/create_users.sql'. You also might want to enable ssl communication to your database server. + +### Webserver + +Install any webserver that's able to communicate with the database you've choosen and clone this repository. Document root for the webserver is 'webapp/www'. The project doesn't work with file extensions (e. g. .php). Therefore, please configure the webserver to search for .php files with the same name if file/folder couldn't be found. + +Example configuration for Apache webserver: + +```text + + + Options Indexes FollowSymLinks Includes ExecCGI + + AllowOverride All + + Require all granted + + + RewriteEngine On + RewriteBase / + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME}.php -f + RewriteRule ^(.+)$ $1.php [L,QSA] + + + +``` + +### Configuration + +Please find 'db_settings.template.json' in the 'config' folder, copy the json file and rename it to 'db_settings.json'. Fill in the information to access the database within the newly generated file. + +Any additional configurations that might be generated by the application during usage will be saved in folder 'config' as well. + +## License + +Shared Household Expenses\ +Copyright (C) 2023 Marco Weingart + +This program is free software: you can redistribute it and/or modify\ +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License\ +along with this program. If not, see . diff --git a/config/db_settings.template.json b/config/db_settings.template.json new file mode 100644 index 0000000..ec1c6ac --- /dev/null +++ b/config/db_settings.template.json @@ -0,0 +1,19 @@ +{ + "general" : { + "fqdn" : "127.0.0.1", + "port" : 3306, + "database" : "shared_household_expenses", + "socket" : "ssl" + }, + + "users" : { + "login" : { + "username" : "she_login", + "password" : "1234" + }, + "admin" : { + "username" : "she_admin", + "password" : "1234" + } + } +} \ No newline at end of file diff --git a/database/create_database.sql b/database/create_database.sql new file mode 100644 index 0000000..a2ce9d5 --- /dev/null +++ b/database/create_database.sql @@ -0,0 +1,20 @@ +/* +Shared Household Expenses +Copyright (C) 2023 Marco Weingart + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +DROP DATABASE IF EXISTS `shared_household_expenses`; +CREATE DATABASE `shared_household_expenses` CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`; diff --git a/database/create_functions.sql b/database/create_functions.sql new file mode 100644 index 0000000..c34d00a --- /dev/null +++ b/database/create_functions.sql @@ -0,0 +1,50 @@ +/* +Shared Household Expenses +Copyright (C) 2023 Marco Weingart + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +USE `shared_household_expenses`; + +DELIMITER $$ + +CREATE FUNCTION `login`( + `try_username` VARCHAR(255), + `try_password` VARCHAR(255) +) +RETURNS INT +LANGUAGE SQL +DETERMINISTIC +READS SQL DATA +SQL SECURITY DEFINER +COMMENT 'Checks if the given username and password match and returns the user_id. If no match was found or password is incorrect 0 is returned.' +BEGIN + + DECLARE returned_user_id INT; + + SELECT user_id INTO returned_user_id + FROM user + WHERE username = try_username AND passwd_hash = PASSWORD(try_password) + LIMIT 1; + + IF returned_user_id IS NULL THEN + SET returned_user_id = 0; + END IF; + + RETURN returned_user_id; + +END; +$$ +DELIMITER ; diff --git a/database/create_tables.sql b/database/create_tables.sql new file mode 100644 index 0000000..ec819dd --- /dev/null +++ b/database/create_tables.sql @@ -0,0 +1,76 @@ +/* +Shared Household Expenses +Copyright (C) 2023 Marco Weingart + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +USE `shared_household_expenses`; + +CREATE TABLE IF NOT EXISTS `retailer` ( + `retailer_id` INT(11) NOT NULL AUTO_INCREMENT, + `retailer` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci', + PRIMARY KEY (`retailer_id`) USING BTREE, + UNIQUE INDEX `retailer` (`retailer`) USING BTREE +) +COLLATE='utf8mb4_unicode_ci' +ENGINE=InnoDB +; + +CREATE TABLE IF NOT EXISTS `purchase` ( + `purchase_id` INT(11) NOT NULL AUTO_INCREMENT, + `timestamp_created` TIMESTAMP NOT NULL DEFAULT current_timestamp(), + `timestamp_updated` TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `article` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci', + `date` DATE NOT NULL, + `retailer_id` INT(11) NOT NULL, + PRIMARY KEY (`purchase_id`) USING BTREE, + INDEX `fk_retailer` (`retailer_id`) USING BTREE, + CONSTRAINT `fk_retailer` FOREIGN KEY (`retailer_id`) REFERENCES `shared_household_expenses`.`retailer` (`retailer_id`) ON UPDATE CASCADE ON DELETE RESTRICT +) +COLLATE='utf8mb4_unicode_ci' +ENGINE=InnoDB +; + +CREATE TABLE IF NOT EXISTS `user` ( + `user_id` INT(11) NOT NULL AUTO_INCREMENT, + `username` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci', + `pretty_name` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci', + `passwd_hash` VARCHAR(255) NOT NULL COLLATE 'utf8mb4_unicode_ci', + `start_value` DECIMAL(20,2) NOT NULL DEFAULT '0.00', + `account_status` SET('READ_WRITE','READ_ONLY','LOCKED','DEACTIVATED') NOT NULL DEFAULT 'READ_WRITE' COLLATE 'utf8mb4_unicode_ci', + PRIMARY KEY (`user_id`) USING BTREE, + UNIQUE INDEX `username` (`username`) USING BTREE, + UNIQUE INDEX `pretty_name` (`pretty_name`) USING BTREE +) +COLLATE='utf8mb4_unicode_ci' +ENGINE=InnoDB +; + +CREATE TABLE IF NOT EXISTS `contribution` ( + `purchase_id` INT(11) NOT NULL, + `contribution_id` INT(11) NOT NULL, + `user_id` INT(11) NOT NULL, + `timestamp_created` TIMESTAMP NOT NULL DEFAULT current_timestamp(), + `timestamp_updated` TIMESTAMP NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + `amount` DECIMAL(20,2) NOT NULL, + `comment` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci', + PRIMARY KEY (`purchase_id`, `contribution_id`) USING BTREE, + INDEX `fk_user` (`user_id`) USING BTREE, + CONSTRAINT `fk_purchase` FOREIGN KEY (`purchase_id`) REFERENCES `shared_household_expenses`.`purchase` (`purchase_id`) ON UPDATE CASCADE ON DELETE CASCADE, + CONSTRAINT `fk_user` FOREIGN KEY (`user_id`) REFERENCES `shared_household_expenses`.`user` (`user_id`) ON UPDATE CASCADE ON DELETE RESTRICT +) +COLLATE='utf8mb4_unicode_ci' +ENGINE=InnoDB +; diff --git a/database/create_users.sql b/database/create_users.sql new file mode 100644 index 0000000..838d7f8 --- /dev/null +++ b/database/create_users.sql @@ -0,0 +1,43 @@ +/* +Shared Household Expenses +Copyright (C) 2023 Marco Weingart + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +USE `shared_household_expenses`; + +DROP USER IF EXISTS 'she_login'@'localhost'; +CREATE USER 'she_login'@'localhost' IDENTIFIED BY '1234'; +GRANT EXECUTE ON FUNCTION shared_household_expenses.login TO 'she_login'@'localhost'; + +DROP USER IF EXISTS 'she_admin'@'localhost'; +CREATE USER 'she_admin'@'localhost' IDENTIFIED BY '1234'; +GRANT DELETE ON shared_household_expenses.contribution TO 'she_admin'@'localhost'; +GRANT DELETE ON shared_household_expenses.purchase TO 'she_admin'@'localhost'; +GRANT INSERT ON shared_household_expenses.contribution TO 'she_admin'@'localhost'; +GRANT INSERT ON shared_household_expenses.purchase TO 'she_admin'@'localhost'; +GRANT INSERT ON shared_household_expenses.retailer TO 'she_admin'@'localhost'; +GRANT INSERT ON shared_household_expenses.user TO 'she_admin'@'localhost'; +GRANT SELECT ON shared_household_expenses.article_list TO 'she_admin'@'localhost'; +GRANT SELECT ON shared_household_expenses.contribution TO 'she_admin'@'localhost'; +GRANT SELECT ON shared_household_expenses.dashboard TO 'she_admin'@'localhost'; +GRANT SELECT ON shared_household_expenses.dashboard_detail TO 'she_admin'@'localhost'; +GRANT SELECT ON shared_household_expenses.purchase TO 'she_admin'@'localhost'; +GRANT SELECT ON shared_household_expenses.retailer TO 'she_admin'@'localhost'; +GRANT SELECT ON shared_household_expenses.user TO 'she_admin'@'localhost'; +GRANT SELECT ON shared_household_expenses.user_contribution TO 'she_admin'@'localhost'; +GRANT UPDATE ON shared_household_expenses.contribution TO 'she_admin'@'localhost'; +GRANT UPDATE ON shared_household_expenses.purchase TO 'she_admin'@'localhost'; +GRANT UPDATE ON shared_household_expenses.user TO 'she_admin'@'localhost'; diff --git a/database/create_views.sql b/database/create_views.sql new file mode 100644 index 0000000..73777b7 --- /dev/null +++ b/database/create_views.sql @@ -0,0 +1,65 @@ +/* +Shared Household Expenses +Copyright (C) 2023 Marco Weingart + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +USE `shared_household_expenses`; + +CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `dashboard` AS +SELECT purchase.purchase_id, purchase.article, retailer.retailer, purchase.date, SUM(contribution.amount) AS amount, +group_concat(DISTINCT CASE +WHEN user.pretty_name IS NULL THEN user.username +ELSE user.pretty_name +END SEPARATOR ' & ') AS contributor +FROM purchase +LEFT JOIN contribution ON purchase.purchase_id = contribution.purchase_id +LEFT JOIN retailer ON purchase.retailer_id = retailer.retailer_id +LEFT JOIN user ON contribution.user_id = user.user_id +GROUP BY purchase.purchase_id +ORDER BY purchase.date DESC, purchase.article ASC; + +CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `user_contribution` AS +SELECT user.user_id, user.username, user.pretty_name, +CASE +WHEN user.pretty_name IS NULL THEN user.username +ELSE user.pretty_name +END display_name, +user.start_value, +CASE +WHEN SUM(contribution.amount) IS NULL THEN 0 +ELSE SUM(contribution.amount) +END sum_contributions, +CASE +WHEN SUM(contribution.amount) IS NULL THEN user.start_value +ELSE user.start_value + SUM(contribution.amount) +END sum_user, +user.account_status +FROM user +LEFT JOIN contribution ON user.user_id = contribution.user_id +GROUP BY contribution.user_id +ORDER BY user.username; + +CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `dashboard_detail` AS +SELECT contribution.purchase_id, contribution.contribution_id, user.username, contribution.amount, contribution.comment +FROM contribution +LEFT JOIN user ON contribution.user_id = user.user_id +ORDER BY purchase_id ASC, username ASC, contribution_id ASC; + +CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `article_list` AS +SELECT article, COUNT(*) AS quantity +FROM purchase +GROUP BY article +ORDER BY article ASC; diff --git a/version b/version new file mode 100644 index 0000000..472de5a --- /dev/null +++ b/version @@ -0,0 +1 @@ +v1.0 \ No newline at end of file diff --git a/webapp/src/get_currency_settings.php b/webapp/src/get_currency_settings.php new file mode 100644 index 0000000..1339545 --- /dev/null +++ b/webapp/src/get_currency_settings.php @@ -0,0 +1,61 @@ +. + + function get_currency_settings() { + // This function checks if the json file with the currency settings exists + // and reads the current settings from it. If custom settings are found within + // the json file the default values will get overwritten. + // + // Returns: + // array: contains currency settings + + // set the default values + $currency_code = "EUR"; + $currency_symbol = "€"; + $currency_decimal = ","; + $currency_position = "after"; + + // Read and decode currency_settings.json if file exists + $file_path = __DIR__."/../../config/currency_settings.json"; + if (file_exists($file_path)) { + + $settings_file = file_get_contents($file_path); + $json = json_decode($settings_file,true); + + // check for each setting if the array key exists and update the default values + if (array_key_exists("currencyCode", $json)) { + $currency_code = $json["currencyCode"]; + } + if (array_key_exists("currencySymbol", $json)) { + $currency_symbol = $json["currencySymbol"]; + } + if (array_key_exists("currencyDecimal", $json)) { + $currency_decimal = $json["currencyDecimal"]; + } + if (array_key_exists("currencyPosition", $json)) { + $currency_position = $json["currencyPosition"]; + } + } + + // Return as array + return array( + "currencyCode" => $currency_code, + "currencySymbol" => $currency_symbol, + "currencyDecimal" => $currency_decimal, + "currencyPosition" => $currency_position); + } +?> diff --git a/webapp/src/get_db_login.php b/webapp/src/get_db_login.php new file mode 100644 index 0000000..cf971dc --- /dev/null +++ b/webapp/src/get_db_login.php @@ -0,0 +1,43 @@ +. + + function get_db_login($db_user) { + // Reads the information stored in the settings json for the database + // connections and returns it. + // + // Args: + // db_user (string): database user whose information should be returned + // + // Returns: + // array: contains informations to connect to the database + + // Read and decode settings.json + $settings_file = file_get_contents(__DIR__.'/../../config/db_settings.json'); + $settings = json_decode($settings_file,true); + + // Extract information + $fqdn = $settings["general"]["fqdn"]; + $user = $settings["users"][$db_user]["username"]; + $password = $settings["users"][$db_user]["password"]; + $database = $settings["general"]["database"]; + $port = $settings["general"]["port"]; + $socket = $settings["general"]["socket"]; + + // Return as array + return array($fqdn, $user, $password, $database, $port, $socket); + } +?> diff --git a/webapp/src/navigation.php b/webapp/src/navigation.php new file mode 100644 index 0000000..a90fdd4 --- /dev/null +++ b/webapp/src/navigation.php @@ -0,0 +1,51 @@ +. +?> + \ No newline at end of file diff --git a/webapp/www/about.php b/webapp/www/about.php new file mode 100644 index 0000000..1d787e6 --- /dev/null +++ b/webapp/www/about.php @@ -0,0 +1,81 @@ + + + + + Über - Shared Household Expenses + + + + + + + + + + +
+ +
+
+
+

Über dieses Projekt

+
+

Verwendete Lizenz

+

+ Shared Household Expenses
+ Copyright (C) 2023 Marco Weingart +

+

+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU 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 General Public License for more details. +

+

+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see https://www.gnu.org/licenses/. +

+

Genutzte Bibliotheken

+

+ CSS-only Material Inputs by Lewis Robinson (12.02.2017)
+ Verfügbar unter https://codepen.io/lewisvrobinson/pen/EyZwjR +

+

+

+

+

+

+

+

+

+

+

Autor

+

+

+

+
+
+ + diff --git a/webapp/www/all.php b/webapp/www/all.php new file mode 100644 index 0000000..8c4537e --- /dev/null +++ b/webapp/www/all.php @@ -0,0 +1,88 @@ + + + + + + Alle Ausgaben - Shared Household Expenses + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+

Alle Ausgaben

+
+
+
+
+ + + +
+
+ + + +
+
+ " onchange="reloadTable('tableHolder')" required> + + +
+
+
+ +
+
+
+
+ +
+
+
close
+ +
+
+ + diff --git a/webapp/www/api/delete-purchase.php b/webapp/www/api/delete-purchase.php new file mode 100644 index 0000000..3945daf --- /dev/null +++ b/webapp/www/api/delete-purchase.php @@ -0,0 +1,57 @@ +. + + // check if the maindata fields match their regpatterns + if (!preg_match("/^[0-9]+$/", $_POST["identifier"])) { + // End execution if regex not ok + echo "Please validate your inputs."; + http_response_code(400); + exit(); + } + + require("../../src/get_db_login.php"); + $db_settings = get_db_login("admin"); + + // connect to database and start a transaction + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + $db->begin_transaction(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT); + + try { + // delete contributions (if any) + $sql = $db->prepare("DELETE FROM contribution WHERE purchase_id = ?"); + $sql->bind_param('i', $_POST['identifier']); + $sql->execute(); + $sql->free_result(); + + // delete purchase + $sql = $db->prepare("DELETE FROM purchase WHERE purchase_id = ?"); + $sql->bind_param('i', $_POST['identifier']); + $sql->execute(); + $sql->free_result(); + + // commit the changes to db + $db->commit(); + + } catch (Exception $ex) { + $db->rollback(); + echo "Error during SQL Execution.\n"; + http_response_code(400); + } + + $db->close(); + +?> diff --git a/webapp/www/api/edit-purchase.php b/webapp/www/api/edit-purchase.php new file mode 100644 index 0000000..e75a8ca --- /dev/null +++ b/webapp/www/api/edit-purchase.php @@ -0,0 +1,253 @@ +. + + if(!isset($_GET['purchase_id'])) { + echo 'purchase_id not present'; + exit(); + } + if (!preg_match("/^[0-9]+$/", $_GET['purchase_id'])) { + echo 'purchase_id not valid'; + exit(); + } + + $purchase_id = $_GET['purchase_id']; + $purchase_timestamp = ""; + $purchase_article = ""; + $purchase_date = ""; + $retailer_id = 0; + $retailer = ""; + $contribution = []; + $user_list = []; + + // Get the informations to connect to database + require("../../src/get_db_login.php"); + $db_settings = get_db_login("admin"); + + // Get the settings for the used currency + require_once("../../src/get_currency_settings.php"); + $currency = get_currency_settings(); + + try { + // Connect to database + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + + // get purchase main data + $sql = "SELECT * FROM purchase WHERE purchase_id = ".$purchase_id." LIMIT 1"; + $res = $db->query($db->real_escape_string($sql)); + while ($row = $res->fetch_assoc()) { + $purchase_timestamp_created = $row['timestamp_created']; + $purchase_timestamp_updated = $row['timestamp_updated']; + $purchase_article = $row['article']; + $purchase_date = $row['date']; + $retailer_id = $row['retailer_id']; + } + + // get purchase retailer + $sql = "SELECT * FROM retailer WHERE retailer_id = ".$retailer_id." LIMIT 1"; + $res = $db->query($db->real_escape_string($sql)); + while ($row = $res->fetch_assoc()) { + $retailer = $row['retailer']; + } + + // get contribution + $i = 0; + $sql = "SELECT * FROM contribution WHERE purchase_id = ".$purchase_id." ORDER BY contribution_id ASC"; + $res = $db->query($db->real_escape_string($sql)); + while ($row = $res->fetch_assoc()) { + $contribution[$i] = array( + 'contribution_id' => $row['contribution_id'], + 'timestamp_created' => $row['timestamp_created'], + 'timestamp_updated' => $row['timestamp_updated'], + 'user_id' => $row['user_id'], + 'amount' => $row['amount'], + 'comment' => $row['comment'] + ); + $i++; + } + unset($i); + + // Select the article list + $sql = "SELECT article FROM article_list"; + $article_list = $db->query($sql); + + // Select all retailers + $sql = "SELECT * FROM retailer ORDER BY retailer"; + $retailer_list = $db->query($sql); + + // Select active users + $sql = "SELECT user_id, username, pretty_name FROM user_contribution WHERE account_status != 'DEACTIVATED' ORDER BY username ASC"; + $res = $db->query($sql); + while ($row = $res->fetch_assoc()) { + $user_list[$row['user_id']] = array( + 'user_id' => $row['user_id'], + 'username' => $row['username'], + 'pretty_name' => $row['pretty_name'] + ); + } + + // Disconnect from Database + $db->close(); + + } catch (Exception $ex) { + echo "Error while receiving Purchase Data."; + exit(); + } + +?> +
+
+

Bearbeiten, Einkauf-ID:

+

Allgemein

+ + +
+
+
Erstellung:
+
+
+
+
Aktualisiert:
+
+
+
+ + fetch_assoc()) { + echo " +
+
+
+
+
+
+
+
+ + fetch_assoc()) { + echo " +
+
+
+
+

Kostenverteilung

+
+
+ + + + + + + + + \n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."\n -->"; + + // Insert each contribution to this purchase from the database + // and prefill the form + $z = 0; + foreach ($contribution as $contri) { + + // cch = current_contrib_html + $cch = $contrib_html; + + // replace placeholder with actual data + $cch = str_replace("", "", $cch); + $cch = str_replace("__", $z, $cch); + $cch = str_replace("_timestamp_", $contri["timestamp_created"], $cch); + $cch = str_replace("_contribution_id_", $contri["contribution_id"], $cch); + $cch = str_replace("_amount_", str_replace(".", $currency["currencyDecimal"], $contri["amount"]), $cch); + $cch = str_replace("_comment_", $contri["comment"], $cch); + $cch = str_replace("", "", $cch); + $cch = str_replace(" +
ErstellungNameBetrag ()Bemerkung
_timestamp_\n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."\n"; + $contrib_html = $contrib_html."
remove
"; + $contrib_html = $contrib_html."
+ + +
add
+
+
+
save
+
delete
+
+
diff --git a/webapp/www/api/edit-user.php b/webapp/www/api/edit-user.php new file mode 100644 index 0000000..12498a6 --- /dev/null +++ b/webapp/www/api/edit-user.php @@ -0,0 +1,91 @@ +. + + if(!isset($_GET['user_id'])) { + echo 'user_id not present'; + exit(); + } + if (!preg_match("/^[0-9]+$/", $_GET['user_id'])) { + echo 'user_id not valid'; + exit(); + } + + $user_id = $_GET['user_id']; + + // Get the informations to connect to database + require("../../src/get_db_login.php"); + $db_settings = get_db_login("admin"); + + // Get the settings for the used currency + require_once("../../src/get_currency_settings.php"); + $currency = get_currency_settings(); + + try { + // Connect to database + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + + // get user data + $sql = "SELECT username, pretty_name, start_value, account_status FROM user WHERE user_id = ".$user_id." LIMIT 1"; + $res = $db->query($db->real_escape_string($sql)); + while ($row = $res->fetch_assoc()) { + $username = $row['username']; + $pretty_name = $row['pretty_name']; + $start_value = str_replace(".", $currency["currencyDecimal"], $row['start_value']); + $account_status = $row['account_status']; + } + + // Disconnect from Database + $db->close(); + + } catch (Exception $ex) { + echo "Error while receiving User Data."; + exit(); + } + +?> +
+
+

Bearbeiten, Nutzer-ID:

+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
save
+
+
diff --git a/webapp/www/api/get-purchase-details.php b/webapp/www/api/get-purchase-details.php new file mode 100644 index 0000000..9a00af8 --- /dev/null +++ b/webapp/www/api/get-purchase-details.php @@ -0,0 +1,129 @@ +. + + if(!isset($_GET['purchase_id'])) { + echo 'purchase_id not present'; + exit(); + } + if (!preg_match("/^[0-9]+$/", $_GET['purchase_id'])) { + echo 'purchase_id not valid'; + exit(); + } + + $purchase_id = $_GET['purchase_id']; + $purchase_timestamp = ""; + $purchase_article = ""; + $purchase_date = ""; + $retailer_id = 0; + $retailer = ""; + $contribution = []; + + // Get the informations to connect to database + require("../../src/get_db_login.php"); + $db_settings = get_db_login("admin"); + + // Get the settings for the used currency + require_once("../../src/get_currency_settings.php"); + $currency = get_currency_settings(); + + try { + // Connect to database + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + + // get purchase main data + $sql = "SELECT * FROM purchase WHERE purchase_id = ".$purchase_id." LIMIT 1"; + $res = $db->query($db->real_escape_string($sql)); + while ($row = $res->fetch_assoc()) { + $purchase_timestamp_created = $row['timestamp_created']; + $purchase_timestamp_updated = $row['timestamp_updated']; + $purchase_article = $row['article']; + $purchase_date = $row['date']; + $retailer_id = $row['retailer_id']; + } + + // get purchase retailer + $sql = "SELECT * FROM retailer WHERE retailer_id = ".$retailer_id." LIMIT 1"; + $res = $db->query($db->real_escape_string($sql)); + while ($row = $res->fetch_assoc()) { + $retailer = $row['retailer']; + } + + // get contribution + $i = 0; + $sql = "SELECT * FROM contribution LEFT JOIN user ON contribution.user_id = user.user_id WHERE purchase_id = ".$purchase_id." ORDER BY contribution_id ASC"; + $res = $db->query($db->real_escape_string($sql)); + while ($row = $res->fetch_assoc()) { + $contribution[$i] = array( + 'timestamp_created' => $row['timestamp_created'], + 'timestamp_updated' => $row['timestamp_updated'], + 'username' => $row['username'], + 'amount' => $row['amount'], + 'comment' => $row['comment'] + ); + $i++; + } + unset($i); + + // Disconnect from Database + $db->close(); + + } catch (Exception $ex) { + echo "Error while receiving Purchase Detail Data."; + exit(); + } + +?> + +

Details zu Einkauf-ID:

+

Allgemein

+

+ Erfasst:
+ Aktualisiert:
+ Artikel:
+ Datum:
+ Händler: +

+

Kostenverteilung

+ + + + + + + + + \n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + ?> +
ErstellungAktualisiertNameBetragBemerkung
".$contri["timestamp_created"]."".$contri["timestamp_updated"]."".$contri["username"].""; + if ($currency["currencyPosition"] == "before") { + echo $currency["currencySymbol"]." "; + echo str_replace(".", $currency["currencyDecimal"], $contri["amount"]); + } else { + echo str_replace(".", $currency["currencyDecimal"], $contri["amount"]); + echo " ".$currency["currencySymbol"]; + } + echo "".$contri["comment"]."
+
edit
diff --git a/webapp/www/api/get-table.php b/webapp/www/api/get-table.php new file mode 100644 index 0000000..cd88dfc --- /dev/null +++ b/webapp/www/api/get-table.php @@ -0,0 +1,131 @@ +. + + // check if the maindata fields match their regpatterns + $all_regex_ok = true; + if (isset($_GET["fromdate"]) && !preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $_GET["fromdate"])) { + $all_regex_ok = false; + } + if (isset($_GET["todate"]) && !preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $_GET["todate"])) { + $all_regex_ok = false; + } + + // End execution if regex not ok + if (!$all_regex_ok) { + echo "Please validate your inputs."; + http_response_code(400); + exit(); + } + + // Build the SQL Statement (from right to left) + $select_statement = ""; + if (isset($_GET['todate'])) { + $select_statement = " date <= '".$_GET['todate']."'"; + } elseif (isset($php_todate)) { + $select_statement = " date <= '".$php_todate."'"; + } + if (isset($_GET['fromdate'])) { + if ($select_statement != "") { + $select_statement = " AND".$select_statement; + } + $select_statement = " date >= '".$_GET['fromdate']."'".$select_statement; + } elseif (isset($php_fromdate)) { + if ($select_statement != "") { + $select_statement = " AND".$select_statement; + } + $select_statement = " date >= '".$php_fromdate."'".$select_statement; + } + if (isset($_GET['fromdate']) || isset($_GET['todate']) || isset($php_fromdate) || isset($php_todate)) { + $select_statement = " WHERE".$select_statement; + } + $select_statement = "SELECT * FROM dashboard".$select_statement; + + // Get the informations to connect to database as editor + if (! @include_once("../src/get_db_login.php")) { + require_once("../../src/get_db_login.php"); + } else { + require_once("../src/get_db_login.php"); + } + + $db_settings = get_db_login("admin"); + + // Get the settings for the used currency + if (! @include_once("../src/get_currency_settings.php")) { + require_once("../../src/get_currency_settings.php"); + } else { + require_once("../src/get_currency_settings.php"); + } + $currency = get_currency_settings(); + + + + try { + // connect to database + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + + // Get table data + $res = $db->query($select_statement); + + // Create Table Head if data has been received + if ($res->num_rows > 0) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } else { + echo "

No Data.

"; + } + + // Display the received data in table + while ($row = $res->fetch_assoc()) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + + // Close Table if data has been received + if ($res->num_rows > 0) { + echo "
ArtikelHändlerDatumBeteiligteGesamt
".$row['article']."".$row['retailer']."".$row['date']."".$row['contributor'].""; + if ($currency["currencyPosition"] == "before") { + echo $currency["currencySymbol"]." "; + echo str_replace(".", $currency["currencyDecimal"], $row['amount']); + } else { + echo str_replace(".", $currency["currencyDecimal"], $row['amount']); + echo " ".$currency["currencySymbol"]; + } + echo "
"; + } + + } catch (Exception $ex) { + echo "Error during SQL Execution."; + http_response_code(400); + } + + // close db connection + if (isset($db)) { + $db->close(); + } + +?> diff --git a/webapp/www/api/insert-purchase.php b/webapp/www/api/insert-purchase.php new file mode 100644 index 0000000..0ffd1c6 --- /dev/null +++ b/webapp/www/api/insert-purchase.php @@ -0,0 +1,167 @@ +. + + function getRetailerID ($retailer_name) { + // gets the retailer_id for the given retailer + // + // Args: + // retailer_name (string): Name of the retailer in question + // + // Returns: + // int: retailer_id + + // Get the informations to connect to database as viewer + $db_settings = get_db_login("admin"); + + // Get the retailer_id from inputDealer if existend, defaults to 0 + $retailer_id = 0; + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + $sql = $db->prepare("SELECT retailer_id FROM retailer WHERE retailer = ? LIMIT 1"); + $sql->bind_param('s', $retailer_name); + $sql->execute(); + $sql->bind_result($retailer_id); // only changes with valid result + $sql->fetch(); + $sql->free_result(); + + // close db connection as user viewer + $db->close(); + + return $retailer_id; + } + + require("../../src/get_db_login.php"); + + // Get the number of dynamic rows + $dynamicRows = (count($_POST) - 4) / 3; + + // check if the maindata fields match their regpatterns + $all_regex_ok = true; + if (!preg_match("/^[\w äöüÄÖÜß&,\._-]+$/", $_POST["inputArticle"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[\w äöüÄÖÜß&,\._-]+$/", $_POST["inputDealer"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $_POST["inputDate"])) { + $all_regex_ok = false; + } + + // check if data in dynamic rows match their regex patterns + // Build Rest of Table + $i = 0; + while ($i < $dynamicRows) { + // Only rows that have inputUser and inputAmount set are being processed + if ($_POST["inputUser".$i] != "" and $_POST["inputAmount".$i] != "") { + if (!preg_match("/^[0-9]+$/", $_POST["inputUser".$i])) { + $all_regex_ok = false; + } + if (!preg_match("/^[-]{0,1}[0-9]+[,\.]{0,1}[0-9]{0,2}$/", $_POST["inputAmount".$i])) { + $all_regex_ok = false; + } + if (!preg_match("/^[\w äöüÄÖÜß&,\._-]*$/", $_POST["inputRemark".$i])) { + $all_regex_ok = false; + } + } + $i++; + } + unset($i); + + // End execution if regex not ok + if (!$all_regex_ok) { + echo "Please validate your inputs."; + http_response_code(400); + exit(); + } + + // Get retailer_id, defaults to 0 if retailer unknown + $retailer_id = getRetailerID($_POST["inputDealer"]); + + // Get the informations to connect to database as editor + $db_settings = get_db_login("admin"); + + // connect to database and start a transaction + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + $db->begin_transaction(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT); + + try { + // create the retailer if it doesn't exist and query the new retailer_id + if ($retailer_id == 0) { + // Insert new retailer + $sql = $db->prepare("INSERT INTO retailer(retailer) VALUES (?)"); + $sql->bind_param('s', $_POST["inputDealer"]); + $sql->execute(); + $sql->free_result(); + + // Get new retailer_id + $sql = $db->prepare("SELECT retailer_id FROM retailer WHERE retailer = ? LIMIT 1"); + $sql->bind_param('s', $_POST["inputDealer"]); + $sql->execute(); + $sql->bind_result($retailer_id); + $sql->fetch(); + $sql->free_result(); + } + + // Get the next purchase_id from purchase + $next_purchase_id; + $sql = $db->prepare("SELECT MAX(purchase_id)+1 AS next_id FROM dashboard"); + $sql->execute(); + $sql->bind_result($next_purchase_id); // changes with valid result + $sql->fetch(); + $sql->free_result(); + + // set default value of 1 for purchase_id (needed for very first entry) + if (!isset($next_purchase_id)) { + $next_purchase_id = 1; + } + + // insert the purchase + $sql = $db->prepare("INSERT INTO purchase(purchase_id, article, date, retailer_id) VALUES (?, ?, ?, ?)"); + $sql->bind_param('issi', $next_purchase_id, $_POST["inputArticle"], $_POST["inputDate"], $retailer_id); + $sql->execute(); + $sql->free_result(); + + // add the contributions (dynamic rows) + $i = 0; + $next_contribution_id = 1; + while ($i < $dynamicRows) { + // Only rows that have inputUser and inputAmount set are being processed + if ($_POST["inputUser".$i] != "" and $_POST["inputAmount".$i] != "") { + + // replace comma with point + $clean_inputAmount = str_replace(",", ".", $_POST["inputAmount".$i]); + + $sql = $db->prepare("INSERT INTO contribution(purchase_id, contribution_id, user_id, amount, comment) VALUES (?, ?, ?, ?, ?)"); + $sql->bind_param('iiids', $next_purchase_id, $next_contribution_id, $_POST["inputUser".$i], $clean_inputAmount, $_POST["inputRemark".$i]); + $sql->execute(); + $sql->free_result(); + $next_contribution_id++; + } + $i++; + } + + // commit the changes to db + $db->commit(); + + } catch (Exception $ex) { + $db->rollback(); + echo "Error during SQL Execution."; + http_response_code(400); + } + + $db->close(); + +?> diff --git a/webapp/www/api/insert-user.php b/webapp/www/api/insert-user.php new file mode 100644 index 0000000..1084228 --- /dev/null +++ b/webapp/www/api/insert-user.php @@ -0,0 +1,76 @@ +. + + require("../../src/get_db_login.php"); + + // check if the maindata fields match their regpatterns + $all_regex_ok = true; + if (!preg_match("/^[a-z]+$/", $_POST["inputUsername"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[\w äöüÄÖÜß,-]*$/", $_POST["inputPrettyName"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[-]{0,1}[0-9]+[,\.]{0,1}[0-9]{0,2}$/", $_POST["inputStartValue"])) { + $all_regex_ok = false; + } + if (!preg_match("/(^READ_ONLY$|^READ_WRITE$|^LOCKED$|^DEACTIVATED$){1}/", $_POST["inputAccountStatus"])) { + $all_regex_ok = false; + } + + // End execution if regex not ok + if (!$all_regex_ok) { + echo "Please validate your inputs."; + http_response_code(400); + exit(); + } + + // Get the informations to connect to database as editor + $db_settings = get_db_login("admin"); + + // connect to database and start a transaction + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + $db->begin_transaction(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT); + + try { + // set pretty_name to NULL if empty + $pretty_name = $_POST["inputPrettyName"]; + if ($pretty_name == "") { + $pretty_name = null; + } + + // format the start value + $start_value = str_replace(",", ".", $_POST["inputStartValue"]); + + // insert the user + $sql = $db->prepare("INSERT INTO user (username, pretty_name, start_value, account_status) VALUES (?, ?, ?, ?)"); + $sql->bind_param('ssds', $_POST["inputUsername"], $pretty_name, $start_value, $_POST['inputAccountStatus']); + $sql->execute(); + $sql->free_result(); + + // commit the changes to db + $db->commit(); + + } catch (Exception $ex) { + $db->rollback(); + echo "Error during SQL Execution.\n"; + http_response_code(400); + } + + $db->close(); + +?> diff --git a/webapp/www/api/new-user.php b/webapp/www/api/new-user.php new file mode 100644 index 0000000..51ff375 --- /dev/null +++ b/webapp/www/api/new-user.php @@ -0,0 +1,87 @@ +. + + // Get the informations to connect to database + require("../../src/get_db_login.php"); + $db_settings = get_db_login("admin"); + + // Get the settings for the used currency + require_once("../../src/get_currency_settings.php"); + $currency = get_currency_settings(); + + // suggested start value is shown in form and should be filled via database to that + // the new user starts with no negative + $suggested_start_value = "0.00"; + + try { + // Connect to database + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + + // get the max user sum so that the new user can start with a difference of 0 to the other users + $sql = $db->prepare("SELECT MAX(sum_user) FROM user_contribution"); + $sql->execute(); + $sql->bind_result($suggested_start_value); + $sql->fetch(); + $sql->free_result(); + + // Disconnect from Database + $db->close(); + + } catch (Exception $ex) { + echo "Error while receiving suggested start value."; + exit(); + } + + // set standard value if response from database was empty + if (!isset($suggested_start_value)) { + $suggested_start_value = "0.00"; + } + + // format start value + $suggested_start_value = str_replace(".", $currency["currencyDecimal"], $suggested_start_value); + +?> +
+
+

Neuen Nutzer erstellen

+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
save
+
+
diff --git a/webapp/www/api/set-global-settings.php b/webapp/www/api/set-global-settings.php new file mode 100644 index 0000000..ac0388a --- /dev/null +++ b/webapp/www/api/set-global-settings.php @@ -0,0 +1,52 @@ +. + + // check if the maindata fields match their regpatterns + $all_regex_ok = true; + if (!preg_match("/^[A-Z]{3}$/", $_POST["currencyCode"])) { + $all_regex_ok = false; + } + if (!preg_match("/^.{1}$/u", $_POST["currencySymbol"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[,\.]{1}$/", $_POST["currencyDecimal"])) { + $all_regex_ok = false; + } + if (!preg_match("/^(before|after){1}$/", $_POST["currencyPosition"])) { + $all_regex_ok = false; + } + + // End execution if regex not ok + if (!$all_regex_ok) { + echo "Please validate your inputs."; + http_response_code(400); + exit(); + } + + // create an array from the inputs + $json = array( + "currencyCode" => $_POST["currencyCode"], + "currencySymbol" => $_POST["currencySymbol"], + "currencyDecimal" => $_POST["currencyDecimal"], + "currencyPosition" => $_POST["currencyPosition"] + ); + + // write contents to file + $settings_file = __DIR__.'/../../../config/currency_settings.json'; + file_put_contents($settings_file, json_encode($json)); + +?> diff --git a/webapp/www/api/update-purchase.php b/webapp/www/api/update-purchase.php new file mode 100644 index 0000000..0303ae6 --- /dev/null +++ b/webapp/www/api/update-purchase.php @@ -0,0 +1,215 @@ +. + + function getRetailerID ($retailer_name) { + // gets the retailer_id for the given retailer + // + // Args: + // retailer_name (string): Name of the retailer in question + // + // Returns: + // int: retailer_id + + // Get the informations to connect to database as viewer + $db_settings = get_db_login("admin"); + + // Get the retailer_id from inputDealer if existend, defaults to 0 + $retailer_id = 0; + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + $sql = $db->prepare("SELECT retailer_id FROM retailer WHERE retailer = ? LIMIT 1"); + $sql->bind_param('s', $retailer_name); + $sql->execute(); + $sql->bind_result($retailer_id); // only changes with valid result + $sql->fetch(); + $sql->free_result(); + + // close db connection as user viewer + $db->close(); + + return $retailer_id; + } + + require("../../src/get_db_login.php"); + + // Get the number of dynamic rows + $dynamicRows = (count($_POST) - 5) / 4; + + // check if the maindata fields match their regpatterns + $all_regex_ok = true; + if (!preg_match("/^[\w äöüÄÖÜß&,\._-]+$/", $_POST["inputArticle"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[\w äöüÄÖÜß&,\._-]+$/", $_POST["inputDealer"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $_POST["inputDate"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[0-9,]*$/", $_POST["deleteContributions"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[0-9]+$/", $_POST["purchaseId"])) { + $all_regex_ok = false; + } + + // check if data in dynamic rows match their regex patterns + // Build Rest of Table + $i = 0; + $z = 0; + while ($z < $dynamicRows) { + // check if current id for dynamicRows is existend. They may not be existend + // when the user deleted a new line within the gui + if (isset($_POST["inputUser".$i])) { + // Only rows that have inputUser and inputAmount set are being processed + if ($_POST["inputUser".$i] != "" and $_POST["inputAmount".$i] != "") { + if (!preg_match("/^[0-9]+$/", $_POST["inputUser".$i])) { + $all_regex_ok = false; + } + if (!preg_match("/^[-]{0,1}[0-9]+[,\.]{0,1}[0-9]{0,2}$/", $_POST["inputAmount".$i])) { + $all_regex_ok = false; + } + if (!preg_match("/^[\w äöüÄÖÜß&,\._-]*$/", $_POST["inputRemark".$i])) { + $all_regex_ok = false; + } + if (!preg_match("/^([0-9]+|new){1}$/", $_POST["contributionId".$i])) { + $all_regex_ok = false; + } + } + $z++; + } + $i++; + } + unset($z); + unset($i); + + // End execution if regex not ok + if (!$all_regex_ok) { + echo "Please validate your inputs."; + http_response_code(400); + exit(); + } + + // Get retailer_id, defaults to 0 if retailer unknown + $retailer_id = getRetailerID($_POST["inputDealer"]); + + // Get the informations to connect to database as editor + $db_settings = get_db_login("admin"); + + // connect to database and start a transaction + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + $db->begin_transaction(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT); + + try { + // create the retailer if it doesn't exist and query the new retailer_id + if ($retailer_id == 0) { + // Insert new retailer + $sql = $db->prepare("INSERT INTO retailer(retailer) VALUES (?)"); + $sql->bind_param('s', $_POST["inputDealer"]); + $sql->execute(); + $sql->free_result(); + + // Get new retailer_id + $sql = $db->prepare("SELECT retailer_id FROM retailer WHERE retailer = ? LIMIT 1"); + $sql->bind_param('s', $_POST["inputDealer"]); + $sql->execute(); + $sql->bind_result($retailer_id); + $sql->fetch(); + $sql->free_result(); + } + + // update the purchase + $sql = $db->prepare("UPDATE purchase SET article = ?, date = ?, retailer_id = ? WHERE purchase_id = ?"); + $sql->bind_param('ssii', $_POST["inputArticle"], $_POST["inputDate"], $retailer_id, $_POST['purchaseId']); + $sql->execute(); + $sql->free_result(); + + // delete contributions (if any) + $deleteContributions = explode(",", $_POST["deleteContributions"]); + $sql = $db->prepare("DELETE FROM contribution WHERE purchase_id = ? AND contribution_id = ?"); + foreach ($deleteContributions as $ContributionIdToDelete) { + if ($ContributionIdToDelete != "") { + $sql->bind_param('ii', $_POST['purchaseId'], $ContributionIdToDelete); + $sql->execute(); + } + } + $sql->free_result(); + + // Get the next free contribution_id for this purchase_id from contributions + $next_contribution_id = 0; + $sql = $db->prepare("SELECT MAX(contribution_id)+1 AS next_id FROM contribution WHERE purchase_id = ?"); + $sql->bind_param('i', $_POST['purchaseId']); + $sql->execute(); + $sql->bind_result($next_contribution_id); + $sql->fetch(); + $sql->free_result(); + if (!$next_contribution_id) { + $next_contribution_id = 1; + } + + // update or add the contributions (dynamic rows) which have not been marked to be deleted + $i = 0; + $z = 0; + while ($z < $dynamicRows) { + // check if current id for dynamicRows is existend. They may not be existend + // when the user deleted a new line within the gui + if (isset($_POST["inputUser".$i])) { + + // Only rows that have inputUser and inputAmount set are being processed + if ($_POST["inputUser".$i] != "" and $_POST["inputAmount".$i] != "") { + + // replace comma with point + $clean_inputAmount = str_replace(",", ".", $_POST["inputAmount".$i]); + + // check if this is a completely new contribution or an update for an existing contribution + if ($_POST["contributionId".$i] == "new") { + // completely new contribution + $sql = $db->prepare("INSERT INTO contribution(purchase_id, contribution_id, user_id, amount, comment) VALUES (?, ?, ?, ?, ?)"); + $sql->bind_param('iiids', $_POST['purchaseId'], $next_contribution_id, $_POST["inputUser".$i], $clean_inputAmount, $_POST["inputRemark".$i]); + $sql->execute(); + $sql->free_result(); + $next_contribution_id++; + + } else { + // might be an update, check if deleted first + if (!in_array($_POST["contributionId".$i], $deleteContributions)) { + // contribution id is not marked to be deleted, update can be applied + $sql = $db->prepare("UPDATE contribution SET user_id = ?, amount = ?, comment = ? WHERE purchase_id = ? AND contribution_id = ?"); + $sql->bind_param('idsii', $_POST["inputUser".$i], $clean_inputAmount, $_POST["inputRemark".$i], $_POST['purchaseId'], $_POST["contributionId".$i]); + $sql->execute(); + $sql->free_result(); + } + } + } + $z++; + } + $i++; + } + unset($i); + unset($z); + + // commit the changes to db + $db->commit(); + + } catch (Exception $ex) { + $db->rollback(); + echo "Error during SQL Execution.\n"; + http_response_code(400); + } + + $db->close(); + +?> diff --git a/webapp/www/api/update-user.php b/webapp/www/api/update-user.php new file mode 100644 index 0000000..79a00bc --- /dev/null +++ b/webapp/www/api/update-user.php @@ -0,0 +1,79 @@ +. + + require("../../src/get_db_login.php"); + + // check if the maindata fields match their regpatterns + $all_regex_ok = true; + if (!preg_match("/^[0-9]+$/", $_POST["userId"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[a-z]+$/", $_POST["inputUsername"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[\w äöüÄÖÜß,-]*$/", $_POST["inputPrettyName"])) { + $all_regex_ok = false; + } + if (!preg_match("/^[-]{0,1}[0-9]+[,\.]{0,1}[0-9]{0,2}$/", $_POST["inputStartValue"])) { + $all_regex_ok = false; + } + if (!preg_match("/(^READ_ONLY$|^READ_WRITE$|^LOCKED$|^DEACTIVATED$){1}/", $_POST["inputAccountStatus"])) { + $all_regex_ok = false; + } + + // End execution if regex not ok + if (!$all_regex_ok) { + echo "Please validate your inputs."; + http_response_code(400); + exit(); + } + + // Get the informations to connect to database as editor + $db_settings = get_db_login("admin"); + + // connect to database and start a transaction + $db = new MySQLi($db_settings[0], $db_settings[1], $db_settings[2], $db_settings[3], $db_settings[4], $db_settings[5]); + $db->begin_transaction(MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT); + + try { + // set pretty_name to NULL if empty + $pretty_name = $_POST["inputPrettyName"]; + if ($pretty_name == "") { + $pretty_name = null; + } + + // format the start value + $start_value = str_replace(",", ".", $_POST["inputStartValue"]); + + // update the user + $sql = $db->prepare("UPDATE user SET username = ?, pretty_name = ?, start_value = ?, account_status = ? WHERE user_id = ?"); + $sql->bind_param('ssdsi', $_POST["inputUsername"], $pretty_name, $start_value, $_POST['inputAccountStatus'], $_POST['userId']); + $sql->execute(); + $sql->free_result(); + + // commit the changes to db + $db->commit(); + + } catch (Exception $ex) { + $db->rollback(); + echo "Error during SQL Execution.\n"; + http_response_code(400); + } + + $db->close(); + +?> diff --git a/webapp/www/content/favicon/favicon-228.png b/webapp/www/content/favicon/favicon-228.png new file mode 100644 index 0000000..66c9b0a Binary files /dev/null and b/webapp/www/content/favicon/favicon-228.png differ diff --git a/webapp/www/content/img/logo-dark.png b/webapp/www/content/img/logo-dark.png new file mode 100644 index 0000000..324c2d6 Binary files /dev/null and b/webapp/www/content/img/logo-dark.png differ diff --git a/webapp/www/content/img/logo-light.png b/webapp/www/content/img/logo-light.png new file mode 100644 index 0000000..92ba3ea Binary files /dev/null and b/webapp/www/content/img/logo-light.png differ diff --git a/webapp/www/content/img/navigation_background.jpg b/webapp/www/content/img/navigation_background.jpg new file mode 100644 index 0000000..7f2efb9 Binary files /dev/null and b/webapp/www/content/img/navigation_background.jpg differ diff --git a/webapp/www/dashboard.php b/webapp/www/dashboard.php new file mode 100644 index 0000000..297d297 --- /dev/null +++ b/webapp/www/dashboard.php @@ -0,0 +1,135 @@ + + + + + + Dashboard - Shared Household Expenses + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+

Dashboard

+
+

Differenz zum größten Anteil

+ query($sql); + $contribution_sum = 0; + if ($res->num_rows > 0) { + $contribution_sum = $res->fetch_row()[0]; + } + + // get the maximum sum of all active users + $sql = "SELECT MAX(sum_user) AS max_user_sum FROM shared_household_expenses.user_contribution WHERE account_status != 'DEACTIVATED'"; + $res = $db->query($sql); + $contribution_max = 0; + if ($res->num_rows > 0) { + $contribution_max = $res->fetch_row()[0]; + } + + // get each active users contribution + $sql = "SELECT * FROM shared_household_expenses.user_contribution WHERE account_status != 'DEACTIVATED'"; + $res = $db->query($sql); + + // Create Cards if data has been received + if ($res->num_rows > 0) { + echo "
\n"; + while ($row = $res->fetch_assoc()) { + $difference = $contribution_max - $row['sum_user']; + if ($difference == 0) { + echo "
\n"; + } else { + echo "
\n"; + } + echo "
\n"; + if ($currency["currencyPosition"] == "before") { + echo $currency["currencySymbol"]." "; + echo str_replace(".", $currency["currencyDecimal"], number_format($difference, 2))."\n"; + } else { + echo str_replace(".", $currency["currencyDecimal"], number_format($difference, 2)); + echo " ".$currency["currencySymbol"]."\n"; + } + echo "
\n"; + echo "
\n"; + echo $row['display_name']."\n"; + echo "
\n"; + echo "
\n"; + } + echo "
\n"; + } else { + echo "

No Data.

"; + } + + $db->close(); + } catch (Exception $ex) { + echo "

Error while querying data from database.

"; + } + ?> +

Ausgaben der letzten 30 Tage

+ +
+
+
+ +
+
+
close
+ +
+
+ + diff --git a/webapp/www/index.php b/webapp/www/index.php new file mode 100644 index 0000000..03f0bbd --- /dev/null +++ b/webapp/www/index.php @@ -0,0 +1,22 @@ + + + diff --git a/webapp/www/new.php b/webapp/www/new.php new file mode 100644 index 0000000..53000cb --- /dev/null +++ b/webapp/www/new.php @@ -0,0 +1,179 @@ + +query($sql); + + // Select all retailers + $sql = "SELECT * FROM retailer ORDER BY retailer"; + $retailer_list = $db->query($sql); + + // Select active users + $sql = "SELECT user_id, username, pretty_name FROM user_contribution WHERE account_status != 'DEACTIVATED' ORDER BY username ASC"; + $user_list = $db->query($sql); + + $db->close(); + } catch (Exception $ex) { + $article_list = false; + $retailer_list = false; + $user_list = false; + } +?> + + + + Neuer Eintrag - Shared Household Expenses + + + + + + + + + + + + + + + +
+ +
+
+
+

Neuen Eintrag erfassen

+
+
+
+

Allgemein

+
+
+
+ + fetch_assoc()) { + echo " + + + +
+
+
+
+ + fetch_assoc()) { + echo " + + + +
+
+ " required> + + +
+
+
+

Kostenverteilung

+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+ +
+
+ + +
+
+
+
+
+ + diff --git a/webapp/www/robots.txt b/webapp/www/robots.txt new file mode 100644 index 0000000..1f53798 --- /dev/null +++ b/webapp/www/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/webapp/www/script/addRemoveRowInEditPurchase.js b/webapp/www/script/addRemoveRowInEditPurchase.js new file mode 100644 index 0000000..a267b7b --- /dev/null +++ b/webapp/www/script/addRemoveRowInEditPurchase.js @@ -0,0 +1,146 @@ +// Shared Household Expenses +// Copyright (C) 2023 Marco Weingart + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +function addEditPurchase() { + // This function reads the base html for a new purchase line with the + // html document, makes it optional and changes the ids accordingly. + // After that the newly generated html is placed inside the html + // document and shown to the user. + + // Copy parent Row to new Variable + let newRow = document.getElementById('new-row-base-html').innerHTML; + + // get the next row id and store the object + let rowIndexObj = document.getElementById('next-row-id'); + let rowIndex = Number(rowIndexObj.innerHTML); + + // make new rows optional by replacing regex '+' with '*' + newRow = newRow.replaceAll("+", "*"); + + // Enable additional Dropdowns to remove value and make them not required + newRow = newRow.replaceAll("disabled=\"\" selected=\"\" value=\"\" hidden=\"\"", "selected=\"\" value=\"\""); + newRow = newRow.replaceAll(". + +function startCheckForm(formID) { + // Adds Event Listener for the specified html form + // + // Args: + // formID (string): id of the dom form element + + const formOnPage = document.getElementById(formID); + if (formOnPage != null) { + stopCheckForm(formID); + formOnPage.addEventListener("keyup", function(dummy) { checkForm(formOnPage); }); + formOnPage.addEventListener("click", function(dummy) { checkForm(formOnPage); }); + checkForm(formOnPage); + } +} + +function stopCheckForm(formID) { + // Removes Event Listener for the specified html form + // + // Args: + // formID (string): id of the dom form element + + const formOnPage = document.getElementById(formID); + if (formOnPage != null) { + formOnPage.removeEventListener("keyup", function(dummy) { checkForm(formOnPage); }); + formOnPage.removeEventListener("click", function(dummy) { checkForm(formOnPage); }); + } +} + +function checkForm(form) { + // Checks the form using multiple functions. If all functions return true + // the submit button becomes active. Otherwise the submit button becomes inactive. + // Returns nothing + // + // Args: + // form (dom element): form to be checked + + // Check the Form using these functions + let checkP = checkPatterns(); + let checkD = checkDependencies(); + + // Locate the submit button and enable it if all checks returned true. Otherwise + // disable the submit button. + let submitBtn = form.querySelector(".submitBtn"); + if (checkP && checkD) { + submitBtn.removeAttribute("disabled"); + submitBtn.className = submitBtn.className.replace(" invalid", ""); + + } else { + submitBtn.setAttribute("disabled", ""); + if (!submitBtn.className.includes("invalid")) { + submitBtn.className = submitBtn.className + " invalid"; + } + } +} + +function checkDependencies() { + // Gets all input elements with depends attribute set. If the current element has more + // than zero chars the element ids mentioned in the depends attribute seperated by space + // are being checked for contents. If the IDs mentioned in the depends attribute don't have + // more than zero chars they receive a special invalid class to highlight them using css. If + // the IDs have more than zero chars the special invalid class gets removed. Returns true if + // all dependencies of input elements with values have values themselfes. Otherwise returns + // false + // + // Returns: + // boolean: true if all dependencies are ok, otherwise false + + // get all input elements that have the attribute pattern + const dependsInputs = document.querySelectorAll('input[depends], select[depends]'); + + // store elements that are not valid with their dependencies + let invalidElements = []; + + for (i = 0; i < dependsInputs.length; i++) { + // get current element + element = dependsInputs[i]; + + // get dependent ids + let dependsIds = element.getAttribute('depends').split(' '); + + if (dependsIds.length > 0) { + // one or more dependencies are set + if (element.value.length > 0) { + + // Element has chars, check if dependencies have chars as well and give them the + // invalid class if they're empty. Otherwise remove invalid class. + for (z = 0; z < dependsIds.length; z++) { + + let extElement = document.getElementById(dependsIds[z]); + if (extElement.value.length > 0) { + // Dependency Element has chars, remove invalid class if set + extElement.className = extElement.className.replace(" invalid", ""); + + } + else { + + // Dependency Element has no chars, set invalid class if not already set + if (!extElement.className.includes("invalid")) { + extElement.className = element.className + " invalid"; + } + + if(!invalidElements.includes(dependsIds[z])) { + invalidElements.push(dependsIds[z]); + } + } + } + } else { + // Element doesn't have any chars. Remove invalid class from dependencies if set + // Only remove if element hasn't been invalid in the current iteration + + for (z = 0; z < dependsIds.length; z++) { + if(!invalidElements.includes(dependsIds[z])) { + let extElement = document.getElementById(dependsIds[z]); + extElement.className = extElement.className.replace(" invalid", ""); + } + } + } + } + } + + if(invalidElements.length == 0) { + return true; + } + return false; +} + +function checkPatterns() { + // Checks all input elements with the pattern attribute set against their + // defined pattern. Input elements with more than zero chars that don't match + // their pattern get an special invalid class assigned to highlight them via css. + // Input elements with zero or more chars that match their pattern lose the + // special invalid class if set. The function returns true if all inputs match their + // Patterns regardless of their char count. Otherwise returns false. + // + // Returns: + // boolean: true if all pattern checks are ok, otherwise false + + // get all input elements that have the attribute pattern + const patternInputs = document.querySelectorAll('input[pattern]'); + + // get all select elements that are required + const requieredSelect = document.querySelectorAll('select'); + + // set true by default. Becomes false as soon as one element doesn't match their + // pattern regardless of char count + let formCompleteNoErrors = true; + + patternInputs.forEach( + function(element) { + // try to match the pattern attribute of the current element + // against its value + const re = new RegExp(element.pattern); + if (re.test(element.value)) { + // Pattern matches, remove invalid class if set + element.className = element.className.replace(" invalid", ""); + + } else if (element.value.length == 0) { + // Pattern doesn't match but input doesn't contain chars + // Remove invalid class if set but make function return false + element.className = element.className.replace(" invalid", ""); + formCompleteNoErrors = false; + + } else { + // Pattern doesen't match input, set invalid class if not already set + // Make function return false + if (!element.className.includes("invalid")) { + element.className = element.className + " invalid"; + } + formCompleteNoErrors = false; + } + } + ); + + requieredSelect.forEach( + function(element) { + if (!element.hasAttribute("optional")) { + if (element.value.length == 0) { + formCompleteNoErrors = false; + } + } + } + ); + + return formCompleteNoErrors; +} diff --git a/webapp/www/script/reloadTable.js b/webapp/www/script/reloadTable.js new file mode 100644 index 0000000..46f9b6e --- /dev/null +++ b/webapp/www/script/reloadTable.js @@ -0,0 +1,56 @@ +// Shared Household Expenses +// Copyright (C) 2023 Marco Weingart + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +function reloadTable(tableHolder) { + // reloads the get-table.php table by using input + // from and to dates. + // + // Args: + // tableHolder (string): id of the dom element which holds the table + + // Build the url + let fromdate = document.getElementById("inputDateFrom").value; + let todate = document.getElementById("inputDateTo").value; + let url="/api/get-table.php?fromdate="+fromdate+"&todate="+todate; + + // Build a new HTTPRequestElement and send the get request + let request = new XMLHttpRequest(); + request.open('GET', url, true); + request.send(); + + // Response received + request.onload = function() { + if (request.status == 200) { + // Successful request. Replace innerHTML for tableHolder + document.getElementById(tableHolder).innerHTML = request.response; + + // execute search if present on site + if (typeof searchTable === "function") { + searchTable(); + } + + } else { + // Request hasn't benn successful, inform user + alert(request.status+": "+request.statusText+"\n"+request.response); + } + }; + + // Request failed + request.onerror = function() { + alert("Request failed."); + }; + +} diff --git a/webapp/www/script/resetToAutofocus.js b/webapp/www/script/resetToAutofocus.js new file mode 100644 index 0000000..8b6969d --- /dev/null +++ b/webapp/www/script/resetToAutofocus.js @@ -0,0 +1,24 @@ +// Shared Household Expenses +// Copyright (C) 2023 Marco Weingart + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +const resetButton = document.querySelector('input[type="reset"]'); +resetButton.addEventListener("click", focusAutofocus); + +function focusAutofocus() { + // sets the focus on the first dom element with the autofocus attribute + + document.querySelector("[autofocus]").focus(); +} diff --git a/webapp/www/script/searchTable.js b/webapp/www/script/searchTable.js new file mode 100644 index 0000000..5f00208 --- /dev/null +++ b/webapp/www/script/searchTable.js @@ -0,0 +1,61 @@ +// Shared Household Expenses +// Copyright (C) 2023 Marco Weingart + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// Add event listener for search field +// document.getElementById("tableSearch").addEventListener("keyup", searchTable); +document.getElementById("tableSearch").addEventListener("input", searchTable); + +function searchTable() { + // Gets the search string from a specific input field and searches all tr-elements + // for this string in their contents. Hides all tr that don't match. + + // get search string + let searchString = document.getElementById("tableSearch").value.toLocaleLowerCase(); + + // get all visible rows that are not hidden via css and not table head + let selectedRows = document.querySelectorAll('tr:not(.hidden, .maintable-head)'); + + // show all selected Rows if there's no (more) search string. otherwise loop though + // each table cell of each row and search for the search string in the values. If + // the search string is not found set the table row to hidden, otherwise show it. + if (searchString == "") { + for (let i = 0; i < selectedRows.length; i++) { + selectedRows[i].hidden = false; + } + } else { + for (let i = 0; i < selectedRows.length; i++) { + + let matchFound = false; + + // get all table cells of current row + let selectedCells = selectedRows[i].querySelectorAll('td'); + + for (let z = 0; z < selectedCells.length; z++) { + if (selectedCells[z].innerText.toLocaleLowerCase().includes(searchString)) { + matchFound = true + } + } + + if (matchFound) { + selectedRows[i].hidden = false; + } else { + selectedRows[i].hidden = true; + } + + } + } + +} diff --git a/webapp/www/script/settings.js b/webapp/www/script/settings.js new file mode 100644 index 0000000..f01973d --- /dev/null +++ b/webapp/www/script/settings.js @@ -0,0 +1,94 @@ +// Shared Household Expenses +// Copyright (C) 2023 Marco Weingart + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +function newUser() { + // Load the UI for creating a new user, place the contents in the fullscreen popup + // and display it. + + // Stop any previous running EventListeners on new User + stopCheckForm('newUserForm'); + + // gets the details-content element where the result will be shown and hide the Details + let targetSpan = document.getElementById("message-content"); + targetSpan.innerHTML = ""; + + // Get the HTML and Database data to create a new user + let request = new XMLHttpRequest(); + request.open('GET', '/api/new-user.php'); + request.send(); + + // Response received + request.onload = function() { + if (request.status == 200) { + // Successful request. Add body to innerHTML or current details + targetSpan.innerHTML = request.response; + document.getElementById("fullscreen-message").setAttribute("style","display: flex"); + + // Add checkForm + startCheckForm('newUserForm'); + } else { + // Request hasn't benn successful, inform user + targetSpan.innerHTML = "Received: "+request.status+": "+request.statusText; + } + }; + + // Request failed + request.onerror = function() { + targetSpan.innerHTML = "Request failed."; + }; + +} + +function editUser(index) { + // Load the UI for changing an existing user, place the contents in the fullscreen popup + // and display it. + // + // Args: + // index (int): user_id for the user to be changed + + // Stop any previous running EventListeners on edit User + stopCheckForm('editUserForm'); + + // gets the details-content element where the result will be shown and hide the Details + let targetSpan = document.getElementById("message-content"); + targetSpan.innerHTML = ""; + + // Get the HTML and Database data to edit the current User + let request = new XMLHttpRequest(); + request.open('GET', '/api/edit-user.php?user_id='+index); + request.send(); + + // Response received + request.onload = function() { + if (request.status == 200) { + // Successful request. Add body to innerHTML or current details + targetSpan.innerHTML = request.response; + document.getElementById("fullscreen-message").setAttribute("style","display: flex"); + + // Add checkForm + startCheckForm('editUserForm'); + } else { + // Request hasn't benn successful, inform user + targetSpan.innerHTML = "Received: "+request.status+": "+request.statusText; + } + }; + + // Request failed + request.onerror = function() { + targetSpan.innerHTML = "Request failed."; + }; + +} diff --git a/webapp/www/script/spanFullscreen.js b/webapp/www/script/spanFullscreen.js new file mode 100644 index 0000000..687b6fc --- /dev/null +++ b/webapp/www/script/spanFullscreen.js @@ -0,0 +1,21 @@ +// Shared Household Expenses +// Copyright (C) 2023 Marco Weingart + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +function removeSpanFullscreen() { + // Hides the fullscreen popup + + document.getElementById("fullscreen-message").setAttribute("style","display: none"); +} diff --git a/webapp/www/script/submitForm.js b/webapp/www/script/submitForm.js new file mode 100644 index 0000000..6d3ee6f --- /dev/null +++ b/webapp/www/script/submitForm.js @@ -0,0 +1,115 @@ +// Shared Household Expenses +// Copyright (C) 2023 Marco Weingart + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +function submitForm(formObject) { + // Parses all input data from the given form and sends it as POST request to the url + // defined in form action. Reloads the current page on success if the form-tag has no + // target attribute. If a target attribute is present the site defined in it is loaded + // upon success. + // + // Args: + // formObject (dom object): dom object of the form + + // check that the pressed submit button is not disabled + if (formObject.querySelector(".submitBtn").classList.contains("invalid")) { + return; + } + + // get the target url + let url = formObject.getAttribute("action"); + + // get all input objects + let inputObjects = formObject.querySelectorAll('input[type=text], input[type=date], input[type=hidden], select'); + + // build the post parameters + let params = ""; + for (let i = 0; i < inputObjects.length; i++) { + if (params != "") { + params = params + "&"; + } + params = params + inputObjects[i].name + "=" + inputObjects[i].value; + } + + // Build a new HTTPRequestElement and send the post request + let request = new XMLHttpRequest(); + request.open('POST', url, true); + request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + request.send(params); + + // Response received + request.onload = function() { + if (request.status == 200) { + // Successful request + // forward to site if specified in form tag or reload the current page + if (formObject.hasAttribute("target")) { + location.href = formObject.getAttribute("target"); + } else { + window.location.reload(true); + } + + } else { + // Request hasn't benn successful, inform user + alert(request.status+": "+request.statusText+"\n"+request.response); + } + }; + + // Request failed + request.onerror = function() { + alert("Request failed."); + }; +} + +function deleteData(formObject, identifier) { + // Sends a post request to an url which is responsible to delete data by using the identifier + // + // Args: + // formObject (dom object): dom object of the form + // identifier (string): identifier of the object to be deleted for the responsible url + + // Ask the user before deleting + let answer = confirm("Sollen dieser Einkauf und dessen Beteiligungen wirklich gelöscht werden?"); + + if (answer) { + // get the target url + let url = formObject.getAttribute("delete-action"); + + // Build the parameter + let params = "identifier=" + String(identifier); + + // Build a new HTTPRequestElement and send the post request + let request = new XMLHttpRequest(); + request.open('POST', url, true); + request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + request.send(params); + + // Response received + request.onload = function() { + if (request.status == 200) { + // Successful request. Alert the user and reload the page + alert("Löschen erfolgreich."); + window.location.reload(true); + } else { + // Request hasn't benn successful, inform user + alert(request.status+": "+request.statusText+"\n"+request.response); + } + }; + + // Request failed + request.onerror = function() { + alert("Request failed."); + }; + } +} diff --git a/webapp/www/script/tableDetails.js b/webapp/www/script/tableDetails.js new file mode 100644 index 0000000..c8efad9 --- /dev/null +++ b/webapp/www/script/tableDetails.js @@ -0,0 +1,85 @@ +// Shared Household Expenses +// Copyright (C) 2023 Marco Weingart + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU 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 General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +function editPurchase(index) { + // Load the UI for the given purchase, place the contents in the fullscreen popup + // and display it. + // + // Args: + // index (int): id of the purchase in question. + + // Stop any previous running EventListeners on edit Purchase + stopCheckForm('editPurchaseForm'); + + // gets the details-content element where the result will be shown and hide the Details + let targetSpan = document.getElementById("message-content"); + targetSpan.innerHTML = ""; + + // Get the HTML and Database data to edit the current purchase + let request = new XMLHttpRequest(); + request.open('GET', '/api/edit-purchase.php?purchase_id='+index); + request.send(); + + // Response received + request.onload = function() { + if (request.status == 200) { + // Successful request. Add body to innerHTML or current details + targetSpan.innerHTML = request.response; + + // Add checkForm + startCheckForm('editPurchaseForm'); + } else { + // Request hasn't benn successful, inform user + targetSpan.innerHTML = "Received: "+request.status+": "+request.statusText; + } + }; + + // Request failed + request.onerror = function() { + targetSpan.innerHTML = "Request failed."; + }; + +} + +function showPurchaseDetails(index) { + // Loads the details of an specific purchase, places them into the fullscreen + // popup and makes the popup visible. + // + // Args: + // index (int): id of the purchase in question + + // Request Details + let request = new XMLHttpRequest(); + request.open('GET', '/api/get-purchase-details.php?purchase_id='+index); + request.send(); + + // Response received + request.onload = function() { + if (request.status == 200) { + // Successful request. Add body to innerHTML or current details + document.getElementById("message-content").innerHTML = request.response; + document.getElementById("fullscreen-message").setAttribute("style","display: flex"); + } else { + // Request hasn't benn successful, inform user + document.getElementById("details-content-"+index).innerHTML = "Received: "+request.status+": "+request.statusText; + } + }; + + // Request failed + request.onerror = function() { + document.getElementById("details-content-"+index).innerHTML = "Request failed."; + }; +} diff --git a/webapp/www/settings.php b/webapp/www/settings.php new file mode 100644 index 0000000..c7d18cb --- /dev/null +++ b/webapp/www/settings.php @@ -0,0 +1,174 @@ + + + + + + Einstellungen - Shared Household Expenses + + + + + + + + + + + + + + + + + + +
+ +
+
+
+

Einstellungen

+
+
+
+
+

Allgemeine Einstellungen

+

+ Gültig für die gesamte Anwendung. +

+
+
+
+ " required> + + +
+
+ " required> + + +
+
+ " required> + + +
+
+ + + +
+
+
+
+ +
+
+
+
+
+
+
+

Nutzereinstellungen

+
+
+ 'DEACTIVATED'"; + $res = $db->query($select_statement); + + // Create Table Head if data has been received + if ($res->num_rows > 0) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } else { + echo "

No Data.

"; + } + + // Display the received data in table + while ($row = $res->fetch_assoc()) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + + // Close Table if data has been received + if ($res->num_rows > 0) { + echo "
NutzernameAnzeigenameStartwertStatus
".$row['username']."".$row['pretty_name'].""; + if ($currency["currencyPosition"] == "before") { echo $currency["currencySymbol"]." "; } + echo str_replace(".", $currency["currencyDecimal"], $row['start_value']); + if ($currency["currencyPosition"] == "after") { echo " ".$currency["currencySymbol"]; } + echo "".$row['account_status']."
edit
"; + } + + // close db connection + if (isset($db)) { + $db->close(); + } + + } catch (Exception $ex) { + echo "Error during SQL Execution."; + } + ?> +
+
+
+ +
+
+
+
+
+
+
+ +
+
+
close
+ +
+
+ + diff --git a/webapp/www/style/css/cards.css b/webapp/www/style/css/cards.css new file mode 100644 index 0000000..864485a --- /dev/null +++ b/webapp/www/style/css/cards.css @@ -0,0 +1,42 @@ +/* + Shared Household Expenses + Copyright (C) 2023 Marco Weingart + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +.card-holder { + width: 100%; +} + +.saldo { + background-color: var(--hl-color); + color: #ffffff; + border-radius: 12px; + width: 250px; + text-align: left; + padding: 10px 15px 15px 15px; + margin: 5px; + box-sizing: border-box; + display: inline-block; +} + +.saldo-max { + background-color: var(--tmp-color-2); +} + +.saldo-sum { + font-weight: bold; + font-size: 26pt; +} diff --git a/webapp/www/style/css/form-detailed.css b/webapp/www/style/css/form-detailed.css new file mode 100644 index 0000000..b30293e --- /dev/null +++ b/webapp/www/style/css/form-detailed.css @@ -0,0 +1,154 @@ +/* + Shared Household Expenses + Copyright (C) 2023 Marco Weingart + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/********************************************************** +The following code partially contains contents from another source. + +Title: CSS-only Material Inputs +Author: Lewis Robinson +Date: February 12, 2017 +Availability: https://codepen.io/lewisvrobinson/pen/EyZwjR + +Copyright (c) 2022 by Lewis Robinson (https://codepen.io/lewisvrobinson/pen/EyZwjR) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in the +Software without restriction, including without limitation the rights 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 +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***********************************************************/ + +.detailed-form input[type="text"], +.detailed-form input[type="date"], +.detailed-form input[type="search"], +.detailed-form select { + width: 100%; + height: 52px; + box-sizing: border-box; + font-family: "Segoe UI", Arial, Helvetica, sans-serif; + background: none; + font-size: 12pt; + color: var(--tmp-color); + padding: 20px 10px 10px 5px; + display: block; + border: none; + border-radius: 0px; + border-bottom: 1px solid var(--tmp-color); + flex: none; +} + +.detailed-form label { + color: var(--tmp-color); + font-size: 12pt; + font-weight: normal; + position: absolute; + pointer-events: none; + left: 10px; + top: 25px; + transition: var(--trans-time) ease all; +} + +.detailed-form input:focus, +.detailed-form select:focus { + outline: none; +} + +.detailed-form input:focus ~ label, +.detailed-form input:valid ~ label, +.detailed-form select:focus ~ label, +.detailed-form select:valid ~ label { + top: 0px; + font-size: 10pt; + color: var(--hl-color); +} + +.detailed-form .bar { + position: relative; + display: block; + width: 0; + height: 2px; + top: -1px; + background: var(--hl-color); + transition: var(--trans-time) ease all; + left: 0%; +} + +.detailed-form input:focus ~ .bar, +.detailed-form select:focus ~ .bar { + width: 100%; +} + +/**************** +* END OF CITATION +****************/ + +.detailed-form .btn { + all: unset; + background: var(--tmp-color); + color: #ffffff; + padding: 10px 20px; + border-radius: 3px; + text-transform: uppercase; + text-decoration: none; + letter-spacing: 2px; + outline: none; + cursor: pointer; + transition: var(--trans-time) ease all; + border-bottom: none; + +} + +.detailed-form .btn-positive { + background: var(--hl-color); +} + +.detailed-form input.submit:disabled, +.detailed-form button:disabled { + cursor: not-allowed; + background: var(--tmp-color-2); +} + +.detailed-form .btn:hover, +.detailed-form .btn:focus, +.detailed-form .btn:focus-visible { + box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.74); +} + +.detailed-form input.invalid ~ label, +.detailed-form select.invalid ~ label { + top: 0px; + font-size: 10pt; + color: var(--neg-color); +} + +.detailed-form input.invalid ~ .bar, +.detailed-form select.invalid ~ .bar { + width: 100%; + background: var(--neg-color); +} diff --git a/webapp/www/style/css/form-simple.css b/webapp/www/style/css/form-simple.css new file mode 100644 index 0000000..739614e --- /dev/null +++ b/webapp/www/style/css/form-simple.css @@ -0,0 +1,55 @@ +/* + Shared Household Expenses + Copyright (C) 2023 Marco Weingart + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +.edit-details { + cursor: pointer; + float: left; +} + +.margin-top-15 { + margin-top: 15px; +} + +.neg-icon { + color: var(--neg-color); +} + +.simple-form input, +.simple-form select { + /* all: unset; */ + box-sizing: border-box; + font-family: "Segoe UI", Arial, Helvetica, sans-serif; + padding: 2px 3px; + margin: none; + border: 2px solid var(--bg-color); + font-size: 12pt; + background-color: var(--tmp-color-2); + width: 100%; + height: 27px; +} + +.simple-form input.invalid { + color: var(--neg-color); +} + +.simple-form input.submit:disabled, +.simple-form button:disabled, +div.submitBtn.invalid { + cursor: not-allowed !important; + color: var(--tmp-color-2) !important; +} diff --git a/webapp/www/style/css/form-structure.css b/webapp/www/style/css/form-structure.css new file mode 100644 index 0000000..59c3c48 --- /dev/null +++ b/webapp/www/style/css/form-structure.css @@ -0,0 +1,96 @@ +/* + Shared Household Expenses + Copyright (C) 2023 Marco Weingart + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +form, +.tableControl { + width: 100%; + max-width: 750px; + margin-left: auto; + margin-right: auto; + display:inline-block; +} + +.form-row { + width: 100%; + box-sizing: border-box; + float: left; +} + +.input-100, +.input-80, +.input-70, +.input-60, +.input-50, +.input-33, +.input-30, +.input-25, +.input-20, +.input-10 { + padding: 5px; + box-sizing: border-box; + float: left; + position: relative; +} + +.input-100 { + width: 100%; +} + +.input-80 { + width: 80%; +} + +.input-70 { + width: 70%; +} + +.input-60 { + width: 60%; +} + +.input-50 { + width: 50%; +} + +.input-33 { + width: 33.3%; +} + +.input-30 { + width: 30%; +} + +.input-25 { + width: 25%; +} + +.input-20 { + width: 20%; +} + +.input-10 { + width: 10%; +} + +.input-l { + text-align: left; +} + +.input-r { + text-align: right; +} diff --git a/webapp/www/style/css/general.css b/webapp/www/style/css/general.css new file mode 100644 index 0000000..d3a6f01 --- /dev/null +++ b/webapp/www/style/css/general.css @@ -0,0 +1,134 @@ +/* + Shared Household Expenses + Copyright (C) 2023 Marco Weingart + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +:root { + --bg-color: white; + --hl-color: #0578f0; + --tmp-color: #4d4d4d; + --tmp-color-2: #cbcbcb; + --neg-color: #cc0c15; + --pos-color: #11ad47; + --trans-time: 300ms; +} + +html { + width: 100%; + height: 100%; +} + +body { + position: relative; + margin: 0px; + font-family: "Segoe UI", Arial, Helvetica, sans-serif; + font-size: 12pt; + display: flex; + justify-content: space-between; + width: 100%; + height: 100%; +} + +a { + text-decoration: none; + color: black; +} + +hr.sep { + background: var(--hl-color); + box-shadow: none; + border: none; + height: 2px; + width: 25%; + margin: 0px auto 0px auto; +} + +.left-wrapper, +.right-wrapper { + display: inline-block; + z-index: 10; +} + +.right-wrapper { + margin-left: 10px; + width: 100%; +} + +.disable-select { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + } + +.hidden { + display: none; +} + +.strikethrough { + text-decoration: line-through; +} + +#content { + width: 100%; + height: 100%; + float: right; + overflow: auto; + justify-content: center; + align-items: center; + text-align: center; +} + +#fullscreen-message { + position: absolute; + z-index: 20; + display: none; + width: 100%; + height: 100%; + max-height: 100%; + overflow-y: auto; + justify-content: center; + align-items: center; +} + +#block-background { + position: absolute; + z-index: 30; + width: 100%; + height: 100%; + opacity: 80%; + background-color: var(--tmp-color); +} + +#message-body { + position: relative; + padding: 30px; + border-radius: 30px; + z-index: 40; + background-color: var(--bg-color); + opacity: 100%; + max-width: 750px; + max-height: 80%; + width: 100%; + overflow-y: auto; +} + +#close-fullscreen-message { + position: absolute; + right: 15px; + top: 15px; + cursor: pointer; +} diff --git a/webapp/www/style/css/navigation.css b/webapp/www/style/css/navigation.css new file mode 100644 index 0000000..a6b04be --- /dev/null +++ b/webapp/www/style/css/navigation.css @@ -0,0 +1,96 @@ +/* + Shared Household Expenses + Copyright (C) 2023 Marco Weingart + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +.nav_link { + text-align: left; + padding-left: 20px; + width: 100%; + height: 50px; + line-height: 50px; + position: relative; + transition: var(--trans-time) ease all; +} + +.nav_link, +.footer_link, +#nav_footer { + color: #ffffff; +} + +.nav_link:hover { + box-shadow: inset 0 0 2000px rgba(255, 255, 255, .5); +} + +#navigation { + background-image: url("/content/img/navigation_background.jpg"); + background-position: left; + background-size: cover; + width: 300px; + height: 100%; + display: flex; + position: relative; + flex-direction: column; + box-shadow: 0 0 5px 0; +} + +#nav_blur { + width: 100%; + height: 100%; + box-shadow: inset 0 0 2000px rgba(0, 0, 0, .5); + backdrop-filter: blur(10px); + display: flex; + position: relative; + flex-direction: column; +} + +#nav_header { + width: 100%; + height: 100px; + display: flex; + justify-content: center; + align-items: center; + position: relative; + flex-direction: column; +} + +#nav_logo { + width: 250px; + height: 75px; + display: block; +} + +#nav_body { + width: 100%; + flex: 1; + flex-direction: column; + overflow-y: auto; + overflow-x: hidden; + position: relative; + margin-bottom: 35px; +} + +#nav_footer { + font-size:8pt; + bottom: 0em; + width: 100%; + height: 35px; + display: flex; + position: absolute; + line-height: 35px; + justify-content: center; +} diff --git a/webapp/www/style/css/table.css b/webapp/www/style/css/table.css new file mode 100644 index 0000000..47b1a28 --- /dev/null +++ b/webapp/www/style/css/table.css @@ -0,0 +1,85 @@ +/* + Shared Household Expenses + Copyright (C) 2023 Marco Weingart + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +.maintable { + border-collapse: collapse; + margin: 0 auto 0 auto; + position: relative; + text-align: left; +} + +tr.maintable { + border: none; + border-collapse: collapse; +} + +td.maintable { + z-index: 11; +} + +th.maintable, +td.maintable { + border: none; + border-collapse: collapse; + padding: 15px 30px; +} + +.maintable-head { + background-color: var(--hl-color); + color: white; + text-transform: uppercase; + position: sticky; + z-index: 12; + top: 0; +} + +.maintable-row { + cursor: pointer; + transition: var(--trans-time) ease all; +} + +.maintable-row:hover { + background-color: var(--tmp-color-2); +} + +.maintable-details { + border-left: 1px solid black; + position: relative; +} + +table.simpletable, +tr.simpletable, +th.simpletable, +td.simpletable { + border-collapse: collapse; + border: 1px solid black; +} + +table.simpletable { + width: 100%; +} + +th.simpletable, +td.simpletable { + padding: 3px 5px; + text-align: left; +} + +.borderless { + border: none !important; +}