mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-25 08:44:42 -04:00
Compare commits
566 Commits
3.3.7
...
revert-inp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0992a92e7 | ||
|
|
e1f8b73005 | ||
|
|
05538570ec | ||
|
|
82aac4ec79 | ||
|
|
d2622e94d7 | ||
|
|
034f79e157 | ||
|
|
c972cdfaf4 | ||
|
|
a1e8841129 | ||
|
|
70ac367761 | ||
|
|
a9fcbc624b | ||
|
|
fd163923ad | ||
|
|
35fe460692 | ||
|
|
0b889ec443 | ||
|
|
154fe9f9e3 | ||
|
|
0bd0d48c91 | ||
|
|
c942f53bf1 | ||
|
|
c39b733c90 | ||
|
|
fea38e1608 | ||
|
|
4436d7396d | ||
|
|
52723ceeec | ||
|
|
b3b8e7ec1d | ||
|
|
8408bb0d80 | ||
|
|
14248edc06 | ||
|
|
061ed57bf2 | ||
|
|
11d5abe6d7 | ||
|
|
e4c1f4a146 | ||
|
|
c384909cf6 | ||
|
|
dfe614efaf | ||
|
|
a1c3b2090b | ||
|
|
07e09e1948 | ||
|
|
f81dfe1b0b | ||
|
|
9fe578504c | ||
|
|
f9f40c7f3c | ||
|
|
46009b2062 | ||
|
|
24772f856f | ||
|
|
857ef96724 | ||
|
|
9da7c73415 | ||
|
|
63ae5494a7 | ||
|
|
1328b4d9b8 | ||
|
|
41d06f5f79 | ||
|
|
5824f78d55 | ||
|
|
17908b55ef | ||
|
|
3963b2c924 | ||
|
|
8d59cd9d83 | ||
|
|
bd1af2b854 | ||
|
|
8886cac056 | ||
|
|
8f52e283bb | ||
|
|
c9c6a88c5d | ||
|
|
2fdddbc043 | ||
|
|
75b00be637 | ||
|
|
dd5a20229d | ||
|
|
0f098bb741 | ||
|
|
1bc3d141e9 | ||
|
|
2985b8c6ae | ||
|
|
87b4526078 | ||
|
|
c60d81dd88 | ||
|
|
141a644d14 | ||
|
|
84e01d14c6 | ||
|
|
3d163e1969 | ||
|
|
a105308ad4 | ||
|
|
70f464c094 | ||
|
|
95a1d0b4f1 | ||
|
|
32c05b475d | ||
|
|
e779ac8a79 | ||
|
|
80e83448ee | ||
|
|
34503b73b8 | ||
|
|
35e3adeca8 | ||
|
|
658a9ce553 | ||
|
|
6b44aea1c5 | ||
|
|
9c0d597159 | ||
|
|
9516073084 | ||
|
|
128ac0c63e | ||
|
|
ffa92dd37c | ||
|
|
3d88d1a387 | ||
|
|
77420083ef | ||
|
|
f5bc497602 | ||
|
|
f75c7fad15 | ||
|
|
1f2d2efbc2 | ||
|
|
e07cfd4143 | ||
|
|
9fc2a4edbd | ||
|
|
ec283e24dc | ||
|
|
b2f5a94859 | ||
|
|
75f435787c | ||
|
|
5e55296ea7 | ||
|
|
9d083f2fe7 | ||
|
|
b07051e448 | ||
|
|
9508770f47 | ||
|
|
9ad99a92e0 | ||
|
|
57755a338d | ||
|
|
18d0345370 | ||
|
|
b593de9f83 | ||
|
|
5500d3989f | ||
|
|
73cec25468 | ||
|
|
8197e1918a | ||
|
|
665ef5aeef | ||
|
|
e8c6d7e01d | ||
|
|
730d01fb74 | ||
|
|
d8ec3a4c6c | ||
|
|
09f84526ac | ||
|
|
865044f114 | ||
|
|
00fed097b0 | ||
|
|
4c689ec6fd | ||
|
|
68d3482065 | ||
|
|
9428d1cd61 | ||
|
|
34476ce374 | ||
|
|
79812c5982 | ||
|
|
c71c75d69f | ||
|
|
34246ee885 | ||
|
|
21c84efd2d | ||
|
|
e71c035671 | ||
|
|
27a4ccdff6 | ||
|
|
ab88f1eec1 | ||
|
|
0f33c399a9 | ||
|
|
9f78a8a075 | ||
|
|
c1c2e9df77 | ||
|
|
3d6f0a912a | ||
|
|
6d37414444 | ||
|
|
a6b674e995 | ||
|
|
a2df771f19 | ||
|
|
9926577b2f | ||
|
|
5b8ccb6e2a | ||
|
|
e327bb3780 | ||
|
|
b42d43d71d | ||
|
|
3555de87f6 | ||
|
|
0fbbc26ab6 | ||
|
|
68d6479f0d | ||
|
|
7356500d86 | ||
|
|
7cb9ffd7aa | ||
|
|
453ee6c061 | ||
|
|
a5b5fccd5e | ||
|
|
20828ea421 | ||
|
|
5d1670fe65 | ||
|
|
2446b23f6e | ||
|
|
c4d293b1a0 | ||
|
|
24fd80e4fd | ||
|
|
183f2472eb | ||
|
|
bf167a06b6 | ||
|
|
b4b0b5ff8b | ||
|
|
5b725d04d5 | ||
|
|
5c0325511c | ||
|
|
a5296e81bb | ||
|
|
204734570b | ||
|
|
cefd200b29 | ||
|
|
61cc93ab57 | ||
|
|
a810100ca1 | ||
|
|
34bc4540bf | ||
|
|
b25273ceee | ||
|
|
a4b3469369 | ||
|
|
84f3bd3bfb | ||
|
|
9315d56408 | ||
|
|
b36ef3a603 | ||
|
|
fba33ed995 | ||
|
|
c0cdff7e11 | ||
|
|
cb1b269d7a | ||
|
|
c01b514596 | ||
|
|
f7bb778351 | ||
|
|
c6d51bff04 | ||
|
|
de9038f450 | ||
|
|
09bf4d2f31 | ||
|
|
7523c0fed8 | ||
|
|
ff4ef97b25 | ||
|
|
5e3fa3c580 | ||
|
|
0669428026 | ||
|
|
9f2474e156 | ||
|
|
9723e82b61 | ||
|
|
8457f1460e | ||
|
|
1789311299 | ||
|
|
6b8d788185 | ||
|
|
dedb6f9836 | ||
|
|
c20153aa00 | ||
|
|
245dcd2dd1 | ||
|
|
33a6356cc4 | ||
|
|
8dbb8f8f69 | ||
|
|
60c3a9a96f | ||
|
|
b4fea6dddc | ||
|
|
681ec28131 | ||
|
|
cd3581ce28 | ||
|
|
b89faa3a94 | ||
|
|
60a5bfdc9a | ||
|
|
47341f1a07 | ||
|
|
29d0703426 | ||
|
|
ff676aeb93 | ||
|
|
05d39ff896 | ||
|
|
b5f93b6325 | ||
|
|
2efda51309 | ||
|
|
728a6a67e0 | ||
|
|
ae44e38855 | ||
|
|
f662f45bf7 | ||
|
|
ac3a11c6a3 | ||
|
|
d18d2cf814 | ||
|
|
cc58cecff0 | ||
|
|
ba9bcd7786 | ||
|
|
88007f56be | ||
|
|
4a23adbb2f | ||
|
|
2245aacf81 | ||
|
|
a8d67895e7 | ||
|
|
2a3317a270 | ||
|
|
1dfa428989 | ||
|
|
01512b0835 | ||
|
|
3e3da57543 | ||
|
|
d5c767aeb9 | ||
|
|
7124e4ca5f | ||
|
|
c8773ad7b1 | ||
|
|
7b224be665 | ||
|
|
588f96a945 | ||
|
|
0754f2f6e6 | ||
|
|
48c04417b8 | ||
|
|
70ee1ed36e | ||
|
|
283ee4d7c6 | ||
|
|
0a527abfa0 | ||
|
|
3890f50e77 | ||
|
|
c4cd60ad58 | ||
|
|
3da79fc47c | ||
|
|
e90029dea6 | ||
|
|
ad9645020c | ||
|
|
2bb4b7c865 | ||
|
|
c971e025b8 | ||
|
|
05372b96cc | ||
|
|
086a90b04d | ||
|
|
6074d984ed | ||
|
|
20bbe8c783 | ||
|
|
a5cdbe4523 | ||
|
|
405583c832 | ||
|
|
6a316c56f6 | ||
|
|
54f5b6fa8f | ||
|
|
e5dcdd5970 | ||
|
|
6b7608fd62 | ||
|
|
43c37da01a | ||
|
|
af21beb19e | ||
|
|
0de0f3ec89 | ||
|
|
aa5bfd9b18 | ||
|
|
3536454638 | ||
|
|
08f1318268 | ||
|
|
397194f2ca | ||
|
|
75d66f62c0 | ||
|
|
b19b4818e3 | ||
|
|
2601fbb7b0 | ||
|
|
e8e3073553 | ||
|
|
6c6b1cb4bc | ||
|
|
8081a98243 | ||
|
|
3025615ff8 | ||
|
|
2fa3ef3c30 | ||
|
|
aa5fd5d0aa | ||
|
|
f661284612 | ||
|
|
fd77dcfc5e | ||
|
|
c5c4a528b4 | ||
|
|
85de6adadb | ||
|
|
93a3788467 | ||
|
|
62cfc67779 | ||
|
|
3072b4c1c0 | ||
|
|
2c4a2f7af1 | ||
|
|
7d791ba59f | ||
|
|
74210bead5 | ||
|
|
044170b2b1 | ||
|
|
8ea5fc5078 | ||
|
|
b4d117011a | ||
|
|
1a465621e0 | ||
|
|
af51e4c735 | ||
|
|
310585d8af | ||
|
|
3690296766 | ||
|
|
9b86ddaac0 | ||
|
|
d47143bfef | ||
|
|
76cefada53 | ||
|
|
2b7e37c8d9 | ||
|
|
78a6316062 | ||
|
|
9e182c323b | ||
|
|
477ceb2317 | ||
|
|
24539101d2 | ||
|
|
f5094d62a2 | ||
|
|
a2610c3bc9 | ||
|
|
4798041408 | ||
|
|
1d87de6f7d | ||
|
|
13a14ec310 | ||
|
|
8d80f5a261 | ||
|
|
145930ce5b | ||
|
|
525c65ffb3 | ||
|
|
2e06f89724 | ||
|
|
ae357cab4a | ||
|
|
38a1815d31 | ||
|
|
1dd58e922f | ||
|
|
4123d9d8f7 | ||
|
|
8526947df1 | ||
|
|
828fd639b2 | ||
|
|
e4fed64976 | ||
|
|
de531e20c6 | ||
|
|
1745e973a1 | ||
|
|
b4f0aaa587 | ||
|
|
2d45ca626b | ||
|
|
f84b795ee6 | ||
|
|
73b189b6d4 | ||
|
|
a6f4558829 | ||
|
|
bfdffbb944 | ||
|
|
7355ee6154 | ||
|
|
6ecacabe16 | ||
|
|
0c1cd830f7 | ||
|
|
83a0ca4a5b | ||
|
|
6c6eb09dcc | ||
|
|
cad41e5576 | ||
|
|
dda927ad09 | ||
|
|
585e674e4d | ||
|
|
d56c78ebc0 | ||
|
|
698f9bb3d7 | ||
|
|
dc943aecb8 | ||
|
|
2618772f20 | ||
|
|
d4ee5c12dd | ||
|
|
1fdebed0e2 | ||
|
|
5cf744d885 | ||
|
|
1b8c66122f | ||
|
|
40a1ec8baf | ||
|
|
eb4ef3f487 | ||
|
|
ead1603213 | ||
|
|
26f10c09b1 | ||
|
|
bf7f2e03b7 | ||
|
|
d21b3f7ba9 | ||
|
|
c0fce5fabb | ||
|
|
9bdaeaa95b | ||
|
|
ed371a0568 | ||
|
|
5b003c6519 | ||
|
|
c00ff28d10 | ||
|
|
351ab93523 | ||
|
|
7c87ac6f60 | ||
|
|
f7b5c6542d | ||
|
|
676e09068e | ||
|
|
f0067757e2 | ||
|
|
5ad8af8fe9 | ||
|
|
7109ab3521 | ||
|
|
4e182fcde8 | ||
|
|
bd65957d02 | ||
|
|
a9e5a0fcfe | ||
|
|
fc15db9d2c | ||
|
|
7db56e8ee8 | ||
|
|
f035fe7ab3 | ||
|
|
8cc8ab61ae | ||
|
|
10b245399d | ||
|
|
4806c0f700 | ||
|
|
82d7f48ee0 | ||
|
|
9f377fa40a | ||
|
|
d0209a711b | ||
|
|
57eb9c1e35 | ||
|
|
5ad6097fd1 | ||
|
|
712d4c60ae | ||
|
|
79618f3877 | ||
|
|
a67872f66d | ||
|
|
8659c17ddd | ||
|
|
dcb797571e | ||
|
|
5bd358dd24 | ||
|
|
427aa592d9 | ||
|
|
6d2e95c4ed | ||
|
|
5852c0a709 | ||
|
|
31ca72fbde | ||
|
|
e6811ce2a1 | ||
|
|
4d960c7b78 | ||
|
|
a1f50e1df7 | ||
|
|
9de467fd30 | ||
|
|
9be17a277a | ||
|
|
6c5982b5f2 | ||
|
|
fd8da94487 | ||
|
|
4c04279b1e | ||
|
|
a56fd88247 | ||
|
|
15edc925ca | ||
|
|
ff4b04757a | ||
|
|
3c5ab264ea | ||
|
|
c85fccd99a | ||
|
|
80cdd2f2d1 | ||
|
|
28ffc64af1 | ||
|
|
ad0476d99e | ||
|
|
bc2d1f587b | ||
|
|
62f53e110e | ||
|
|
cf5e6dee39 | ||
|
|
8890dc30e8 | ||
|
|
35d44ffccc | ||
|
|
b69280ec55 | ||
|
|
6459ee7ddb | ||
|
|
3004f1e9ea | ||
|
|
ab88c76596 | ||
|
|
0e697e3c53 | ||
|
|
75c61b3e49 | ||
|
|
cf45b25a3a | ||
|
|
5347c4981b | ||
|
|
383ffd2e73 | ||
|
|
a981387e9f | ||
|
|
90ad5ae115 | ||
|
|
568678587e | ||
|
|
eed0cd1ca0 | ||
|
|
a312434b87 | ||
|
|
69b2c4c51c | ||
|
|
f2faf1cf32 | ||
|
|
2c508f3fe5 | ||
|
|
20fad5890f | ||
|
|
099d324d2e | ||
|
|
2fe82484d7 | ||
|
|
ea99d0234d | ||
|
|
0f435621ad | ||
|
|
fda088d4f2 | ||
|
|
d71c831a58 | ||
|
|
fb40550756 | ||
|
|
bb2fc5e888 | ||
|
|
d6a35c66f5 | ||
|
|
782438892e | ||
|
|
9d5d1ced07 | ||
|
|
beea0efee8 | ||
|
|
f73740547b | ||
|
|
d125c8a5d7 | ||
|
|
610fdf9213 | ||
|
|
21d41ae371 | ||
|
|
a35004f1a5 | ||
|
|
8c40242a4c | ||
|
|
ca7ea81769 | ||
|
|
05df1dae4b | ||
|
|
d5b4a2745e | ||
|
|
fd96bac495 | ||
|
|
52d1da53d0 | ||
|
|
abf5bffeff | ||
|
|
a045296b77 | ||
|
|
04fb87fd8e | ||
|
|
89d7fcc3ca | ||
|
|
51daf2b70e | ||
|
|
8a2f125c52 | ||
|
|
0f83096296 | ||
|
|
6f0b35bb2c | ||
|
|
003f68a681 | ||
|
|
f696731b1d | ||
|
|
d8ade4b023 | ||
|
|
36e3861894 | ||
|
|
1657510ca2 | ||
|
|
7215747000 | ||
|
|
71bfb4681b | ||
|
|
a98fa2b166 | ||
|
|
922d8491da | ||
|
|
b7b8c314c7 | ||
|
|
580f04dea4 | ||
|
|
3422a15fb1 | ||
|
|
3392c5357f | ||
|
|
dd329840dc | ||
|
|
a79d553d5c | ||
|
|
1eead53cd7 | ||
|
|
8a8235c1e5 | ||
|
|
c28a7fba63 | ||
|
|
ecbb00fb1b | ||
|
|
08f6a1a151 | ||
|
|
f9a6d8ce77 | ||
|
|
253e76b21d | ||
|
|
312b965c66 | ||
|
|
8bdbd77422 | ||
|
|
af286f00b9 | ||
|
|
dac42b1630 | ||
|
|
3a92ec0da7 | ||
|
|
3766a90540 | ||
|
|
0d2affadc5 | ||
|
|
e5b8a2063f | ||
|
|
6556e40aff | ||
|
|
3a0b0af047 | ||
|
|
6d3eee6bea | ||
|
|
cfdc3cf9a8 | ||
|
|
5ecb68a384 | ||
|
|
3c4dff5ac1 | ||
|
|
eacd7d1f07 | ||
|
|
702d0c773c | ||
|
|
56994b1b85 | ||
|
|
6c7ff029d3 | ||
|
|
57662183f9 | ||
|
|
98eff67702 | ||
|
|
1547663439 | ||
|
|
babe06132c | ||
|
|
db9da86df5 | ||
|
|
b44993f2fa | ||
|
|
3c32944ce9 | ||
|
|
8d8487a637 | ||
|
|
b449c10f0d | ||
|
|
a91f21ca05 | ||
|
|
a501dc9b99 | ||
|
|
06ca9e9f74 | ||
|
|
56bb57ba8a | ||
|
|
20dad261fd | ||
|
|
6c60a6aa78 | ||
|
|
e48f408635 | ||
|
|
87af7df2a5 | ||
|
|
67aadb48ae | ||
|
|
5248e964ff | ||
|
|
fd474f548e | ||
|
|
78d2ca72b2 | ||
|
|
ed7613b7da | ||
|
|
0b2198e229 | ||
|
|
5f5fe5eb47 | ||
|
|
1da81e95b3 | ||
|
|
c45e164a83 | ||
|
|
2bf9effe1d | ||
|
|
bd4ec13b9a | ||
|
|
44651de42b | ||
|
|
ffe49278fc | ||
|
|
2eb6d85818 | ||
|
|
d5e371d0ef | ||
|
|
306cfbef7c | ||
|
|
9ce55583f5 | ||
|
|
f2dd1131a2 | ||
|
|
4df6d708dc | ||
|
|
dbf2ee711e | ||
|
|
aff43196eb | ||
|
|
8d8d9b7b54 | ||
|
|
76a96503da | ||
|
|
6cfb6abbf9 | ||
|
|
b864e684b6 | ||
|
|
1516006646 | ||
|
|
86757cb11a | ||
|
|
96abcf6ba9 | ||
|
|
4ae8505a19 | ||
|
|
5b6ada58d4 | ||
|
|
d2301dbfde | ||
|
|
0ec9a85990 | ||
|
|
6181953039 | ||
|
|
d81d0b2fc5 | ||
|
|
b37cc5ee8b | ||
|
|
5daed8cc84 | ||
|
|
8ea4869f4d | ||
|
|
2b3818c5da | ||
|
|
1bb96f6dda | ||
|
|
f3f1d0e28c | ||
|
|
05229bc2f6 | ||
|
|
fbb4739673 | ||
|
|
90186bc667 | ||
|
|
bd9d2c00a7 | ||
|
|
e91fcd8bb9 | ||
|
|
d44dbb8760 | ||
|
|
1649b81038 | ||
|
|
16ded77931 | ||
|
|
f8f186ca2e | ||
|
|
94bd295188 | ||
|
|
0aa2dd3f6c | ||
|
|
cbed9e4882 | ||
|
|
31fa79e27a | ||
|
|
7f1411edbc | ||
|
|
2e41975c4e | ||
|
|
1740a69e7c | ||
|
|
0544e13211 | ||
|
|
2da2895062 | ||
|
|
f11f4eeb2d | ||
|
|
71efb0262f | ||
|
|
f061a83317 | ||
|
|
e09875e5f3 | ||
|
|
6a244d1beb | ||
|
|
5695b74f1b | ||
|
|
77393d1d21 | ||
|
|
b366641fbc | ||
|
|
bde0dc0b7c | ||
|
|
f99d0dca8d | ||
|
|
24f8c94c49 | ||
|
|
7e3d048bfc | ||
|
|
122a827645 | ||
|
|
427c4c7d3d | ||
|
|
6ca1cb739f | ||
|
|
070d989548 | ||
|
|
cd0132c22c | ||
|
|
9f8cf48467 | ||
|
|
206b56333a | ||
|
|
cf59d6779e | ||
|
|
68ed73ab3b | ||
|
|
e5236dd510 | ||
|
|
d1f8c15f3e | ||
|
|
6810f613a0 | ||
|
|
3980f248ed | ||
|
|
bf2cf416db | ||
|
|
772d42490b | ||
|
|
c580e4cdee | ||
|
|
efe4becfab | ||
|
|
d1c25991fe | ||
|
|
528ebf8e20 |
7
.bowerrc
7
.bowerrc
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"directory": "public/bower_components",
|
||||
"scripts": {
|
||||
"postinstall": "grunt default genlicense",
|
||||
"postuninstall": "grunt default genlicense"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
node_modules
|
||||
tmp
|
||||
application/config/email.php
|
||||
app/Config/Email.php
|
||||
*.patch
|
||||
patches/
|
||||
.idea/
|
||||
@@ -10,10 +10,15 @@ git-svn-diff.py
|
||||
.buildpath
|
||||
.project
|
||||
.settings/*
|
||||
.git
|
||||
dist/
|
||||
node_modules/
|
||||
*.swp
|
||||
*.rej
|
||||
*.orig
|
||||
*~
|
||||
*.~
|
||||
*.log
|
||||
application/sessions/*
|
||||
app/writable/session/*
|
||||
!app/writable/session/index.html
|
||||
|
||||
|
||||
22
.editorconfig
Normal file
22
.editorconfig
Normal file
@@ -0,0 +1,22 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = tab
|
||||
insert_final_newline = true
|
||||
max_line_length = 120
|
||||
tab_width = 4
|
||||
|
||||
[{*.cjs,*.js}]
|
||||
indent_style = tab
|
||||
|
||||
[{*.ctp,*.hphp,*.inc,*.module,*.php,*.php4,*.php5,*.phtml}]
|
||||
indent_style = tab
|
||||
|
||||
[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,composer.lock,jest.config}]
|
||||
indent_style = tab
|
||||
|
||||
[{*.htm,*.html,*.ng,*.sht,*.shtm,*.shtml}]
|
||||
indent_style = tab
|
||||
86
.env
Normal file
86
.env
Normal file
@@ -0,0 +1,86 @@
|
||||
#--------------------------------------------------------------------
|
||||
# ENVIRONMENT
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
CI_ENVIRONMENT = production
|
||||
CI_DEBUG = false
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# APP
|
||||
#--------------------------------------------------------------------
|
||||
app.appTimezone = 'UTC'
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# DATABASE
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
database.default.hostname = 'localhost'
|
||||
database.default.database = 'ospos'
|
||||
database.default.username = 'admin'
|
||||
database.default.password = 'pointofsale'
|
||||
database.default.DBDriver = 'MySQLi'
|
||||
database.default.DBPrefix = 'ospos_'
|
||||
database.default.port = 3306
|
||||
|
||||
database.development.hostname = 'localhost'
|
||||
database.development.database = 'ospos'
|
||||
database.development.username = 'admin'
|
||||
database.development.password = 'pointofsale'
|
||||
database.development.DBDriver = 'MySQLi'
|
||||
database.development.DBPrefix = 'ospos_'
|
||||
database.development.port = 3306
|
||||
|
||||
database.tests.hostname = 'localhost'
|
||||
database.tests.database = 'ospos'
|
||||
database.tests.username = 'admin'
|
||||
database.tests.password = 'pointofsale'
|
||||
database.tests.DBDriver = 'MySQLi'
|
||||
database.tests.DBPrefix = 'ospos_'
|
||||
database.tests.charset = utf8mb4
|
||||
database.tests.DBCollat = utf8mb4_general_ci
|
||||
database.tests.port = 3306
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# EMAIL
|
||||
#--------------------------------------------------------------------
|
||||
email.SMTPHost = ''
|
||||
email.SMTPUser = ''
|
||||
email.SMTPPass = ''
|
||||
email.SMTPPort =
|
||||
email.SMTPTimeout = 5
|
||||
email.SMTPCrypto = 'tls'
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# ENCRYPTION
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
encryption.key = ''
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# HONEYPOT
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
honeypot.hidden = true
|
||||
honeypot.label = 'Fill This Field'
|
||||
honeypot.name = 'honeypot'
|
||||
honeypot.template = '<label>{label}</label><input type="text" name="{name}" value=""/>'
|
||||
honeypot.container = '<div style="display:none">{template}</div>'
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# LOGGER
|
||||
# - 0 = Disables logging, Error logging TURNED OFF
|
||||
# - 1 = Emergency Messages - System is unusable
|
||||
# - 2 = Alert Messages - Action Must Be Taken Immediately
|
||||
# - 3 = Critical Messages - Application component unavailable, unexpected exception.
|
||||
# - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
|
||||
# - 5 = Warnings - Exceptional occurrences that are not errors.
|
||||
# - 6 = Notices - Normal but significant events.
|
||||
# - 7 = Info - Interesting events, like user logging in, etc.
|
||||
# - 8 = Debug - Detailed debug information.
|
||||
# - 9 = All Messages
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
logger.threshold = 0
|
||||
app.db_log_enabled = false
|
||||
app.db_log_only_long = false
|
||||
63
.env-example
Normal file
63
.env-example
Normal file
@@ -0,0 +1,63 @@
|
||||
#--------------------------------------------------------------------
|
||||
# ENVIRONMENT
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
CI_ENVIRONMENT = production
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# DATABASE
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
database.default.hostname = 'localhost'
|
||||
database.default.database = 'ospos'
|
||||
database.default.username = 'admin'
|
||||
database.default.password = 'pointofsale'
|
||||
database.default.DBDriver = 'MySQLi'
|
||||
database.default.DBPrefix = 'ospos_'
|
||||
|
||||
database.development.hostname = 'localhost'
|
||||
database.development.database = 'ospos'
|
||||
database.development.username = 'admin'
|
||||
database.development.password = 'pointofsale'
|
||||
database.development.DBDriver = 'MySQLi'
|
||||
database.development.DBPrefix = 'ospos_'
|
||||
|
||||
database.tests.hostname = 'localhost'
|
||||
database.tests.database = 'ospos'
|
||||
database.tests.username = 'admin'
|
||||
database.tests.password = 'pointofsale'
|
||||
database.tests.DBDriver = 'MySQLi'
|
||||
database.tests.DBPrefix = 'ospos_'
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# ENCRYPTION
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
encryption.key = ''
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# LOGGER
|
||||
# - 0 = Disables logging, Error logging TURNED OFF
|
||||
# - 1 = Emergency Messages - System is unusable
|
||||
# - 2 = Alert Messages - Action Must Be Taken Immediately
|
||||
# - 3 = Critical Messages - Application component unavailable, unexpected exception.
|
||||
# - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
|
||||
# - 5 = Warnings - Exceptional occurrences that are not errors.
|
||||
# - 6 = Notices - Normal but significant events.
|
||||
# - 7 = Info - Interesting events, like user logging in, etc.
|
||||
# - 8 = Debug - Detailed debug information.
|
||||
# - 9 = All Messages
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
logger.threshold = 0
|
||||
app.db_log_enabled = false
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# HONEYPOT
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
honeypot.hidden = true
|
||||
honeypot.label = 'Fill This Field'
|
||||
honeypot.name = 'honeypot'
|
||||
honeypot.template = '<label>{label}</label><input type="text" name="{name}" value=""/>'
|
||||
honeypot.container = '<div style="display:none">{template}</div>'
|
||||
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -1,3 +1,3 @@
|
||||
dist/ merge=ours
|
||||
application/language/**/*.php merge=ours
|
||||
text=auto
|
||||
app/Language/**/*.php merge=ours
|
||||
text=auto eol=lf
|
||||
|
||||
119
.github/ISSUE_TEMPLATE/bug report.yml
vendored
Normal file
119
.github/ISSUE_TEMPLATE/bug report.yml
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
name: Bug Report
|
||||
description: File a bug report
|
||||
title: "[Bug]: "
|
||||
labels: ["bug", "triage"]
|
||||
projects: ["ospos/3", "ospos/4"]
|
||||
assignees:
|
||||
- none
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Bug reports indicate that something is not working as intended.
|
||||
Please include as much detail as possible and submit a separate bug report for each problem.
|
||||
Do not include personal identifying information such as email addresses or encryption keys.
|
||||
- type: textarea
|
||||
id: bug-description
|
||||
attributes:
|
||||
label: Bug Description?
|
||||
description: Describe the problem that you are seeing
|
||||
placeholder: "Describe the problem that you are seeing"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: steps-reproduce
|
||||
attributes:
|
||||
label: Steps to Reproduce?
|
||||
description: List the steps to reproduce this issue
|
||||
placeholder: "Steps to Reproduce"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: Expected Behavior?
|
||||
description: Tell us what did you expect to happen?
|
||||
placeholder: "Expected Behavior"
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: ospos-version
|
||||
attributes:
|
||||
label: OpensourcePOS Version
|
||||
description: What version of our software are you running?
|
||||
options:
|
||||
- opensourcepos 3.3.9
|
||||
- opensourcepos 3.3.8
|
||||
- opensourcepos 3.3.7
|
||||
- development (unreleased)
|
||||
default: 0
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: php-version
|
||||
attributes:
|
||||
label: Php version
|
||||
description: What version of Php?
|
||||
options:
|
||||
- Php 7.2
|
||||
- Php 7.3
|
||||
- Php 7.4
|
||||
- Php 8.1
|
||||
- Php 8.2
|
||||
- Php 8.3
|
||||
- Php 8.4
|
||||
default: 0
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: browsers
|
||||
attributes:
|
||||
label: What browsers are you seeing the problem on?
|
||||
multiple: true
|
||||
options:
|
||||
- Firefox
|
||||
- Chrome
|
||||
- Safari
|
||||
- Microsoft Edge
|
||||
- Other
|
||||
- type: input
|
||||
id: server
|
||||
attributes:
|
||||
label: Server Operating System and version
|
||||
description: "Server Operating System "
|
||||
placeholder: "Server Operating System "
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: database
|
||||
attributes:
|
||||
label: Database Management System and version
|
||||
description: "Database Management System"
|
||||
placeholder: "Database Management"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: webserver
|
||||
attributes:
|
||||
label: Web Server and version
|
||||
description: "Web Server and version "
|
||||
placeholder: "Web Server and version "
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: servers
|
||||
attributes:
|
||||
label: System Information Report (optional)
|
||||
description: Copy and paste from OSPOS > Configuration > Setup & Conf > Setup & Conf?
|
||||
placeholder: System Information Report
|
||||
value: "System Information Report"
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Unmodified copy of OpensourcePOS
|
||||
description: By submitting this issue you agree this copy has not been modified
|
||||
options:
|
||||
- label: I agree this copy has not been modified
|
||||
required: true
|
||||
63
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
63
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
name: ✨ Feature Request
|
||||
description: Suggest an idea for this project
|
||||
title: "[Feature]: "
|
||||
labels: ["enhancement"]
|
||||
assignees: ["none"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this feature request! 🤗
|
||||
Please make sure this feature request hasn't been already submitted by someone by looking through other open/closed issues. 😃
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
multiple: false
|
||||
label: Type of Feature
|
||||
description: Select the type of feature request.
|
||||
options:
|
||||
- "✨ New Feature"
|
||||
- "📝 Documentation"
|
||||
- "🎨 Style and UI"
|
||||
- "🔨 Code Refactor"
|
||||
- "⚡ Performance Improvements"
|
||||
- "✅ New Test"
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: ospos-version
|
||||
attributes:
|
||||
label: OpensourcePOS Version
|
||||
description: What version of our software are you running?
|
||||
options:
|
||||
- opensourcepos 3.3.9
|
||||
- opensourcepos 3.3.8
|
||||
- opensourcepos 3.3.7
|
||||
default: 0
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: Give us a brief description of the feature or enhancement you would like
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: additional-information
|
||||
attributes:
|
||||
label: Additional Information
|
||||
description: Give us some additional information on the feature request like proposed solutions, links, screenshots, etc.
|
||||
|
||||
- type: checkboxes
|
||||
id: terms
|
||||
attributes:
|
||||
label: Verify you searched open requests in OpensourcePOS
|
||||
description: By submitting this request you agree that you have searched Open Requests in the Tracker
|
||||
options:
|
||||
- label: I agree I have searched Open Requests
|
||||
required: true
|
||||
|
||||
54
.gitignore
vendored
54
.gitignore
vendored
@@ -1,33 +1,15 @@
|
||||
# Dependency directories
|
||||
/node_modules
|
||||
/vendor
|
||||
/public/bower_components
|
||||
|
||||
# Logs
|
||||
/application/logs/*
|
||||
*.log
|
||||
node_modules
|
||||
vendor
|
||||
public/resources
|
||||
app/Config/email.php
|
||||
npm-debug.log*
|
||||
|
||||
# Build generated
|
||||
/tmp
|
||||
/public/license/.licenses
|
||||
/public/license/bower.LICENSES
|
||||
/public/dist
|
||||
|
||||
# Docker
|
||||
!/docker/.env
|
||||
/docker/data/database/db/*
|
||||
/docker/data/certbot/conf/*
|
||||
/docker/data/ospos/app/*
|
||||
|
||||
# Database
|
||||
/database/database.sql
|
||||
/database/migrate_phppos_dist.sql
|
||||
|
||||
# Use files
|
||||
/application/config/email.php
|
||||
/application/sessions/*
|
||||
/application/uploads/*
|
||||
!docker/.env
|
||||
docker/data/database/db/*
|
||||
docker/data/certbot/conf/*
|
||||
docker/data/ospos/app/*
|
||||
|
||||
# Editors
|
||||
## SublimeText
|
||||
@@ -69,11 +51,11 @@ $RECYCLE.BIN/
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Other
|
||||
/generate_langauges.php
|
||||
/dist
|
||||
/docs
|
||||
generate_languages.php
|
||||
dist
|
||||
docs
|
||||
/patches
|
||||
/translations
|
||||
translations
|
||||
/.buildpath
|
||||
/.project
|
||||
/.settings/*
|
||||
@@ -81,6 +63,7 @@ $RECYCLE.BIN/
|
||||
git-svn-diff.py
|
||||
*.bash
|
||||
.swp
|
||||
system/
|
||||
*.swp
|
||||
*.rej
|
||||
*.orig
|
||||
@@ -88,3 +71,14 @@ git-svn-diff.py
|
||||
*.~
|
||||
.env
|
||||
auth.json
|
||||
|
||||
*.png
|
||||
*.jpg
|
||||
*.jpeg
|
||||
*.webp
|
||||
*copy*
|
||||
/writable/logs/*.log
|
||||
/writable/debugbar/*.json
|
||||
/app/Database/database.sql
|
||||
/writable/cache/settings
|
||||
/.env.bak
|
||||
|
||||
46
.htaccess
46
.htaccess
@@ -1,9 +1,15 @@
|
||||
# redirect to public page
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_URI} !^public$
|
||||
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge [NC]
|
||||
RewriteRule "^(.*)$" "/public/" [R=301,L]
|
||||
RewriteEngine On
|
||||
|
||||
RewriteCond %{REQUEST_URI} !^public$
|
||||
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge [NC]
|
||||
RewriteRule "^(.*)$" "/public/" [R=301,L]
|
||||
|
||||
# If you installed CodeIgniter in a subfolder, you will need to
|
||||
# change the following line to match the subfolder you need. Uncomment
|
||||
# the line below and comment the line above.
|
||||
#RewriteRule "^(.*)$" "/[SUBDIRECTORY]/public/" [R=301,L]
|
||||
</IfModule>
|
||||
|
||||
# disable directory browsing
|
||||
@@ -17,7 +23,6 @@ IndexIgnore *
|
||||
Header always set X-Frame-Options "SAMEORIGIN"
|
||||
</Ifmodule>
|
||||
|
||||
# Apache 2.4
|
||||
<IfModule authz_core_module>
|
||||
# secure htaccess file
|
||||
<Files .htaccess>
|
||||
@@ -39,34 +44,3 @@ IndexIgnore *
|
||||
Require all denied
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
|
||||
# Apache 2.2
|
||||
<IfModule !authz_core_module>
|
||||
# secure htaccess file
|
||||
<Files .htaccess>
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
Satisfy all
|
||||
</Files>
|
||||
|
||||
# prevent access to PHP error log
|
||||
<Files error_log>
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
Satisfy all
|
||||
</Files>
|
||||
|
||||
# prevent access to LICENSE
|
||||
<Files LICENSE>
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
Satisfy all
|
||||
</Files>
|
||||
|
||||
# prevent access to csv, txt and md files
|
||||
<FilesMatch "\.(csv|txt|md|yml|json|lock)$">
|
||||
Order allow,deny
|
||||
Deny from all
|
||||
Satisfy all
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
|
||||
45
.php-cs-fixer.no-header.php
Normal file
45
.php-cs-fixer.no-header.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter 4 framework.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use CodeIgniter\CodingStandard\CodeIgniter4;
|
||||
use Nexus\CsConfig\Factory;
|
||||
use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer;
|
||||
use Nexus\CsConfig\FixerGenerator;
|
||||
use PhpCsFixer\Finder;
|
||||
|
||||
$finder = Finder::create()
|
||||
->files()
|
||||
->in([
|
||||
__DIR__ . '/app',
|
||||
__DIR__ . '/public',
|
||||
])
|
||||
->exclude(['Views/errors/html'])
|
||||
->append([
|
||||
__DIR__ . '/admin/starter/builds',
|
||||
]);
|
||||
|
||||
$overrides = [
|
||||
// for updating to coding-standard
|
||||
'modernize_strpos' => true,
|
||||
];
|
||||
|
||||
$options = [
|
||||
'cacheFile' => 'build/.php-cs-fixer.no-header.cache',
|
||||
'finder' => $finder,
|
||||
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
|
||||
'customRules' => [
|
||||
NoCodeSeparatorCommentFixer::name() => true,
|
||||
],
|
||||
];
|
||||
|
||||
return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects();
|
||||
46
.travis.yml
46
.travis.yml
@@ -5,41 +5,32 @@ branches:
|
||||
- weblate
|
||||
services:
|
||||
- docker
|
||||
before_install:
|
||||
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
- sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||
- sudo apt-get update
|
||||
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
|
||||
- docker --version
|
||||
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
|
||||
- chmod +x docker-compose
|
||||
- sudo mv docker-compose /usr/local/bin
|
||||
|
||||
dist: jammy
|
||||
language: node_js
|
||||
node_js:
|
||||
- 20
|
||||
script:
|
||||
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
- docker run --rm -v $(pwd):/app jekkos/composer composer install
|
||||
- docker run --rm -v $(pwd):/app jekkos/composer php bin/install.php translations develop
|
||||
- sed -i "s/'\(dev\)'/'$rev'/g" application/config/config.php
|
||||
- version=$(grep application_version application/config/config.php | sed "s/.*=\s'\(.*\)';/\1/g")
|
||||
- docker run --rm -u $(id -u) -v $(pwd):/app opensourcepos/composer:ci4 composer install
|
||||
- version=$(grep application_version app/Config/App.php | sed "s/.*=\s'\(.*\)';/\1/g")
|
||||
- sed -i "s/commit_sha1 = 'dev'/commit_sha1 = '$rev'/g" app/Config/OSPOS.php
|
||||
- echo "$version-$branch-$rev"
|
||||
- npm version "$version-$branch-$rev" --force || true
|
||||
- docker run --rm -it -v $(pwd):/app -w /app opensourcepos/node-grunt-bower
|
||||
sh -c "npm install && bower install && grunt package"
|
||||
- npm ci && npm install -g gulp && npm run build
|
||||
- docker build . --target ospos -t ospos
|
||||
- docker-compose -f docker-compose.test.yml up --abort-on-container-exit
|
||||
- docker build database/ -t jekkos/opensourcepos:sqlscript
|
||||
- docker build app/Database/ -t "jekkos/opensourcepos:sql-$TAG"
|
||||
env:
|
||||
global:
|
||||
- DOCKER_COMPOSE_VERSION=1.29.1
|
||||
- BRANCH=$(echo ${TRAVIS_BRANCH} | sed s/feature\\///)
|
||||
- TAG=${TRAVIS_TAG:-$BRANCH}
|
||||
- date=`date +%Y%m%d%H%M%S` && branch=${TRAVIS_BRANCH} && rev=`git rev-parse --short=6 HEAD`
|
||||
after_success:
|
||||
- TAG=${TRAVIS_TAG:-$BRANCH}
|
||||
- docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD" && docker tag "ospos:latest"
|
||||
"jekkos/opensourcepos:$TAG" && docker push "jekkos/opensourcepos:$TAG" && docker push "jekkos/opensourcepos:sqlscript"
|
||||
- sudo mv dist/opensourcepos.tgz "dist/opensourcepos.$version.$rev.tgz"
|
||||
before_deploy:
|
||||
- npm set //npm.pkg.github.com/:_authToken "$NPM_TOKEN"
|
||||
"jekkos/opensourcepos:$TAG" && docker push "jekkos/opensourcepos:$TAG" && docker push "jekkos/opensourcepos:sql-$TAG"
|
||||
- gulp compress
|
||||
- mv dist/opensourcepos.tar.gz "dist/opensourcepos.$version.$rev.tgz"
|
||||
- mv dist/opensourcepos.zip "dist/opensourcepos.$version.$rev.zip"
|
||||
deploy:
|
||||
- provider: npm
|
||||
file: dist/opensourcepos.$version.$rev.tgz
|
||||
@@ -47,21 +38,22 @@ deploy:
|
||||
email: jeroen@steganos.dev
|
||||
skip_cleanup: true
|
||||
api_key:
|
||||
secure: "bmOfMoGBi+wTEdTbIB7wPenNTCZrmHAa05xZnMxZSOjxplZpnZSO4Tvnnkihz9LpbF3xT1hm76AJJuZonu2HKtUez+6L4Fg+i/jS8Ij/BZlbvKBVTeB+2yN09ncXNmObnl1bShtm90d2WYQJKk3NJGuEboFQNxwJLYJXg33iMhc="
|
||||
secure: "DNPJOrT51wdO0BAbkX2hKowdXYh7x8d43xvAw7eVfOslyBPiv6Bb/1QdC2Bpnlqe0WiJVS5hvBTMrJ+vSDK5i/l8jA+ZoI6ms1+P1DQ6sBBMBQI2fuvRCrJj+Fp3WnaduZb/N7R+FqdKQwD/ZORyhzJ4whtHkrO8uC7cY/wlacU="
|
||||
|
||||
on:
|
||||
all_branches: true
|
||||
- provider: releases
|
||||
file: dist/opensourcepos.$version.$rev.tgz
|
||||
file: dist/opensourcepos.$version.$rev.zip
|
||||
name: "OpensourcePos $version"
|
||||
release_notes_file: WHATS_NEW.txt
|
||||
release_notes_file: CHANGELOG.md
|
||||
prerelease: true
|
||||
skip_cleanup: true
|
||||
|
||||
user: jekkos
|
||||
overwrite: true
|
||||
api_key:
|
||||
secure: Ax25mMRDfHVf/HjRwqxYJe2oMnWC4sc2aKIiUxAOviVJJSCl4GMWhcFlUNnFsDcKIg2ofEGMVD6b9cTBuOwPDvymUDFnLNCCgDWve+vRDdWaTkTipn77Qk4c9UO9VvuzlPSKopChefPHlQ0n1rEmAMiKIXuqjUlNGqybW4FLP4E=
|
||||
secure: "DNPJOrT51wdO0BAbkX2hKowdXYh7x8d43xvAw7eVfOslyBPiv6Bb/1QdC2Bpnlqe0WiJVS5hvBTMrJ+vSDK5i/l8jA+ZoI6ms1+P1DQ6sBBMBQI2fuvRCrJj+Fp3WnaduZb/N7R+FqdKQwD/ZORyhzJ4whtHkrO8uC7cY/wlacU="
|
||||
|
||||
on:
|
||||
tags: true
|
||||
branch: master
|
||||
|
||||
67
BUILD.md
Normal file
67
BUILD.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# Building OSPOS
|
||||
|
||||
## For Developers and Hobbyists Only
|
||||
|
||||
If you are a developer and need to add unique features to OSPOS, you can download the raw code from the github repository and make changes. If it's a really cool change that might benefit others, we ask that you consider contributing it to the project.
|
||||
|
||||
After you've made your changes, you will need to do a "BUILD" on it to add all necessary components that OSPOS needs to be a fully functional application.
|
||||
|
||||
This documents the "How to Build" process.
|
||||
|
||||
The goal here is to set up and configure the build process so that the actual build is as simple as possible.
|
||||
|
||||
The build process uses the build tools "npm" and "gulp" to piece everything together.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Install the latest version of NPM (tested using version 9.4.2)
|
||||
- Install the latest version of Composer (tested using composer 2.5.1)
|
||||
|
||||
## The Workflow
|
||||
|
||||
1. Download the code from the master branch found at https://github.com/opensourcepos/opensourcepos/tree/master.
|
||||
2. Unzip it and copy the contents into the working folder.
|
||||
3. Start a terminal session from the root of your working folder. For example, I normally open up the working folder in PHPStorm and run the commands from the Terminal provided by the IDE.
|
||||
4. Enter the following three commands in sequence:
|
||||
- `composer install`
|
||||
- `npm install`
|
||||
- `npm run build`
|
||||
|
||||
That's all there is to it.
|
||||
|
||||
Note: If you receive messages similar to 'codeigniter4/framework v4.3.1 requires ext-intl', this is an indicator that you do not have intl enabled in php.ini
|
||||
|
||||
After the build tasks are complete, if you have the database set up and a preconfigured copy of .env, just drop the .env file into the root of the working folder. You should be ready to go.
|
||||
|
||||
If you do not have an existing (and upgraded) database, then you will need to continue from this point forward with the standard installation instructions, but at this point you have a runnable version of OSPOS.
|
||||
|
||||
### Windows Platform
|
||||
|
||||
Using an `.env` file is a convenient approach to store OSPOS configuration.
|
||||
|
||||
I've added the following Powershell scripts to make my life a bit easier, which I share with you.
|
||||
|
||||
* `build.ps1` - Which runs the build but also restores the .env from a backup I make of it in a specifically placed folder. I place a copy of the configured .env file in a folder that has the following path from the working folder: `../env/<working-folder-name>/.env`
|
||||
|
||||
### Containerized setup
|
||||
Development using docker has the advantage that all the application's dependencies are contained within the docker environment. During development we want to have a live version of the code in the container when we edit it. This is accomplished by mounting the application folder within the /app of the docker container.
|
||||
|
||||
The file permissions for the repository in the container should be the same as on the host. That's why we have to startthe PHP process in docker with the host current uid.
|
||||
|
||||
```
|
||||
export USERID=$(id -u)
|
||||
export GROUPID=$(id -g)
|
||||
docker-compose -f docker-compose.dev.yml up
|
||||
```
|
||||
|
||||
## The Result
|
||||
|
||||
The build creates a developer version of a runnable instance of OSPOS. It contains a ton of developer stuff that **should not be deployed to a production environment**.
|
||||
|
||||
Again, the results of this build is NOT something that should be used for production.
|
||||
|
||||
However, the zip and tar files, found in the root `dist` folder, are created as part of the build process and can be used for deploying a ***trial production*** instance of OSPOS.
|
||||
|
||||
Only official releases should be used for real production. There is significant risk of failure should you chose to deploy a development branch or even a master branch that the development team hasn't signed off on.
|
||||
|
||||
Good luck with your build. Please report any issues you encounter.
|
||||
59
CHANGELOG.md
59
CHANGELOG.md
@@ -1,5 +1,8 @@
|
||||
[unreleased]: https://github.com/opensourcepos/opensourcepos/compare/3.3.7...HEAD
|
||||
[3.3.6]: https://github.com/opensourcepos/opensourcepos/compare/3.3.6...3.3.7
|
||||
[unreleased]: https://github.com/opensourcepos/opensourcepos/compare/3.3.9...HEAD
|
||||
[3.3.9]: https://github.com/opensourcepos/opensourcepos/compare/3.3.8...3.3.9
|
||||
[3.3.8]: https://github.com/opensourcepos/opensourcepos/compare/3.3.7...3.3.8
|
||||
[3.3.7]: https://github.com/opensourcepos/opensourcepos/compare/3.3.6...3.3.7
|
||||
[3.3.6]: https://github.com/opensourcepos/opensourcepos/compare/3.3.5...3.3.6
|
||||
[3.3.5]: https://github.com/opensourcepos/opensourcepos/compare/3.3.4...3.3.5
|
||||
[3.3.4]: https://github.com/opensourcepos/opensourcepos/compare/3.3.3...3.3.4
|
||||
[3.3.3]: https://github.com/opensourcepos/opensourcepos/compare/3.3.2...3.3.3
|
||||
@@ -19,29 +22,41 @@
|
||||
[2.3.4]: https://github.com/opensourcepos/opensourcepos/compare/2.3.3...2.3.4
|
||||
[2.3.3]: https://github.com/opensourcepos/opensourcepos/compare/2.3.2...2.3.3
|
||||
[2.3.2]: https://github.com/opensourcepos/opensourcepos/compare/2.3.1...2.3.2
|
||||
[2.3.1]: https://github.com/opensourcepos/opensourcepos/compare/2.3.0...2.3.1
|
||||
[2.3.0]: https://github.com/opensourcepos/opensourcepos/compare/2.2.2...2.3.0
|
||||
[2.3.1]: https://github.com/opensourcepos/opensourcepos/compare/2.3...2.3.1
|
||||
[2.3.0]: https://github.com/opensourcepos/opensourcepos/compare/2.2.2...2.3
|
||||
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented here.
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
List of changes in the `master` branch.
|
||||
- Bump framework to CodeIgniter `4.x.x`
|
||||
- Improve security performance against bots
|
||||
|
||||
- N/A
|
||||
## [3.3.9] - 2023-11-06
|
||||
|
||||
## [3.3.7] - 2022-04-26
|
||||
- Translation updates (Arabic, Central Khmer, Croatian, Czech, Danish, English, French, Indonesian, Lao, Russian, Spanish, Thai)
|
||||
- Fix logout race condition issue ([#3578](https://github.com/opensourcepos/opensourcepos/issues/3578))
|
||||
- Fix docker compose file ([#3754](https://github.com/opensourcepos/opensourcepos/issues/3754))
|
||||
- Minor report fixes
|
||||
|
||||
- Translation updates (Thai, Indonesian, Swedish, Italian)
|
||||
## [3.3.8] - 2022-08-03
|
||||
|
||||
- Translation updates (Azerbaijani, Flemish, French, Spanish, Thai, Vietnamese)
|
||||
- Fix logo removal issue (CSRF regression) ([#3533](https://github.com/opensourcepos/opensourcepos/issues/3533))
|
||||
- Substract refunds from total rewards as payment method ([#3536](https://github.com/opensourcepos/opensourcepos/issues/3536))
|
||||
|
||||
## [3.3.7] - 2022-03-29
|
||||
|
||||
- Translation updates (Chinese, French, Indonesian, Italian, Polish, Swedish, Thai)
|
||||
- XSS fixes in bootstrap datatables
|
||||
- Invoice numbering fixes
|
||||
- Docker compose database scripts are now mounted from a container volume
|
||||
|
||||
## [3.3.6] - 2022-01-08
|
||||
## [3.3.6] - 2021-10-31
|
||||
|
||||
- Translation updates (Hungarian, Indonesian, Bosnian, Ukranian, Vietnamese, Spanish)
|
||||
- Translation updates (Bosnian, Dutch, Indonesian, Polish, Russian, Spanish)
|
||||
- Make footer revision clickable (ref to github)
|
||||
- Minor reporting adjustments
|
||||
- Introduced new global keyboard shortcuts (see overview below)
|
||||
@@ -57,9 +72,9 @@ List of changes in the `master` branch.
|
||||
- Type juggling password fix for old logins
|
||||
|
||||
|
||||
## [3.3.5] - 2021-08-26
|
||||
## [3.3.5] - 2021-08-26 [YANKED]
|
||||
|
||||
- Translation updates (Romanian, Ukrainian, Vietnamese, Thai, Polish, Swedish, Portuguese, Arabic, French, Chinese, Dutch, Tamil, Turkish, Spanish)
|
||||
- Translation updates (Arabic, Azerbaijani, Bulgarian, Chinese, Dutch, French, Indonesian, Polish, Portuguese, Romanian, Spanish, Swedish, Tamil, Thai, Turkish, Ukrainian, Vietnamese)
|
||||
- New responsive login page based on Bootstrap `5`
|
||||
- Translation fallback to English when a string is untranslated for the selected language
|
||||
- Database and performance optimizations
|
||||
@@ -75,7 +90,7 @@ List of changes in the `master` branch.
|
||||
- Fixes for Docker to make it run on Windows
|
||||
- Blind SQL injection fix
|
||||
|
||||
## [3.3.4] - 2021-04-18
|
||||
## [3.3.4] - 2021-04-20
|
||||
|
||||
- Translation updates (Hungarian, Indonesian, Bosnian, Ukrainian, Vietnamese, Spanish)
|
||||
- Prevent data wipeout when calling GET directly on the save endpoint
|
||||
@@ -90,7 +105,7 @@ List of changes in the `master` branch.
|
||||
- Add barcode field to item kits
|
||||
- Fix discount register parsing in some specific locales
|
||||
|
||||
## [3.3.3] - 2020-12-31
|
||||
## [3.3.3] - 2021-01-01
|
||||
|
||||
- PHP `7.4` support
|
||||
- Set PHP `7.2` to be the minimum level due to older version deprecations
|
||||
@@ -100,13 +115,13 @@ List of changes in the `master` branch.
|
||||
- Improved security (CSRF protection)
|
||||
- Various small improvements and bug fixes
|
||||
|
||||
## [3.3.2] - 2020-09-02
|
||||
## [3.3.2] - 2020-09-03
|
||||
|
||||
- Fixed `only_full_group_by` issue with MySQL/MariaDB
|
||||
- Fixed POS transaction return failure if items were deleted
|
||||
- Various bug fixes
|
||||
|
||||
## [3.3.1] - 2019-12-04
|
||||
## [3.3.1] - 2019-12-14
|
||||
|
||||
- Various bug fixes (please disable `only_full_group_by` option from MySQL/MariaDB to avoid issues)
|
||||
|
||||
@@ -235,7 +250,7 @@ List of changes in the `master` branch.
|
||||
- Fixed `phppos to ospos` database migration script
|
||||
- Minor bug fixes and some general code clean up
|
||||
|
||||
## [3.0.0] 2016-10-21
|
||||
## [3.0.0] 2016-10-22
|
||||
|
||||
- Upgrade CodeIgniter to version `3.1.0`
|
||||
- Major UI overhaul based on Bootstrap `3.0` and Bootswatch Themes
|
||||
@@ -254,7 +269,7 @@ List of changes in the `master` branch.
|
||||
- About 280 closed issues under `3.0.0` release label, too many to produce a meaningful list
|
||||
- Various code cleanup, refactoring, optimization and etc.
|
||||
|
||||
## [2.4.0] - 2016-04-02
|
||||
## [2.4.0] - 2016-10-03
|
||||
|
||||
- Upgrade CodeIgniter to version `3.0.5`
|
||||
- Fix for spurious logouts
|
||||
@@ -283,7 +298,7 @@ List of changes in the `master` branch.
|
||||
- Minor code cleanup
|
||||
- Removal of annoying backup prompt on logout
|
||||
|
||||
## [2.3.3] - 2016-01-05
|
||||
## [2.3.3] - 2016-01-06
|
||||
|
||||
- Item kit fixes (search, list, ...)
|
||||
- Add date picker widgets in sale/receiving edit forms
|
||||
@@ -305,7 +320,7 @@ List of changes in the `master` branch.
|
||||
- Add SQL script to clean zeroes in sales/receivings comments
|
||||
- Numerous other bug fixes
|
||||
|
||||
## [2.3.2] - 2015-07-15
|
||||
## [2.3.2] - 2016-01-25
|
||||
|
||||
- Nominatim (OpenStreetMap) customer address autocompletion
|
||||
- Sale invoice templating
|
||||
@@ -336,7 +351,7 @@ List of changes in the `master` branch.
|
||||
- Fix item import through CSV
|
||||
- Bug fixes for reports
|
||||
|
||||
## [2.3.0] - 2014-08-19
|
||||
## [2.3.0] - 2014-08-20
|
||||
|
||||
- Support for multiple stock locations
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# package.json
|
||||
|
||||
## scripts
|
||||
|
||||
`npm run scriptname`
|
||||
|
||||
- `clean` - wipe the dependencies downloaded by Composer, Bower, and npm
|
||||
```
|
||||
grunt clean:composer & grunt clean:bower & grunt clean:npm
|
||||
```
|
||||
- `install` - automatically runs the Composer and Bower install commands after installing the npm dependencies
|
||||
```
|
||||
composer install & bower install
|
||||
```
|
||||
- `update` - updates Composer and the dependencies downloaded by Composer and npm
|
||||
```
|
||||
npm update & composer self-update & composer update
|
||||
```
|
||||
|
||||
## devDependencies
|
||||
|
||||
- `grunt` - used for copying files downloaded by npm
|
||||
- `grunt-contrib-clean` - Grunt plugin to clean files before copying
|
||||
- `grunt-contrib-copy` - Grunt plugin to copy files downloaded by npm
|
||||
- `npm` - downloads project dependencies
|
||||
- the others are unlisted for now, because this will probably change pretty significantly in the near future
|
||||
|
||||
## dependencies
|
||||
|
||||
- `bootstrap` - main CSS framework used
|
||||
- `bootswatch` - themes for the UI
|
||||
|
||||
## devDependencies (global)
|
||||
|
||||
- `bower` - for the time being, Bower is still necessary
|
||||
|
||||
|
||||
# composer.json
|
||||
|
||||
## require
|
||||
|
||||
- `php` - this application runs on PHP
|
||||
- `codeigniter/framework` - the CodeIgniter PHP framework this application is build on
|
||||
- `dompdf/dompdf` - no description
|
||||
- `tamtamchik/namecase` - no description
|
||||
- `paragonie/random_compat` - no description
|
||||
- `vlucas/phpdotenv` - no description
|
||||
|
||||
## require-dev
|
||||
|
||||
- `mikey179/vfsstream` - no description
|
||||
- `phpunit/phpunit` - no description
|
||||
- `kenjis/ci-phpunit-test` - no description
|
||||
27
Dockerfile
27
Dockerfile
@@ -1,19 +1,15 @@
|
||||
FROM php:7.4-apache AS ospos
|
||||
FROM php:8.2-apache AS ospos
|
||||
LABEL maintainer="jekkos"
|
||||
|
||||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
libicu-dev \
|
||||
libgd-dev \
|
||||
openssl
|
||||
|
||||
RUN a2enmod rewrite headers
|
||||
RUN apt update && apt-get install -y libicu-dev libgd-dev
|
||||
RUN a2enmod rewrite
|
||||
RUN docker-php-ext-install mysqli bcmath intl gd
|
||||
RUN echo "date.timezone = \"\${PHP_TIMEZONE}\"" > /usr/local/etc/php/conf.d/timezone.ini
|
||||
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN ln -s /app/*[^public] /var/www && rm -rf /var/www/html && ln -nsf /app/public /var/www/html
|
||||
RUN chmod -R 750 /app/public/uploads /app/application/logs && chown -R www-data:www-data /app/public /app/application
|
||||
RUN chmod -R 770 /app/writable/uploads /app/writable/logs /app/writable/cache && chown -R www-data:www-data /app
|
||||
|
||||
FROM ospos AS ospos_test
|
||||
|
||||
@@ -23,17 +19,20 @@ RUN apt-get install -y libzip-dev wget git
|
||||
RUN wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -O /bin/wait-for-it.sh && chmod +x /bin/wait-for-it.sh
|
||||
RUN docker-php-ext-install zip
|
||||
RUN composer install -d/app
|
||||
RUN php /app/vendor/kenjis/ci-phpunit-test/install.php -a /app/application -p /app/vendor/codeigniter/framework
|
||||
RUN sed -i 's/backupGlobals="true"/backupGlobals="false"/g' /app/application/tests/phpunit.xml
|
||||
RUN sed -i '13,17d' /app/application/tests/controllers/Welcome_test.php
|
||||
WORKDIR /app/application/tests
|
||||
#RUN sed -i 's/backupGlobals="true"/backupGlobals="false"/g' /app/tests/phpunit.xml
|
||||
WORKDIR /app/tests
|
||||
|
||||
CMD ["/app/vendor/phpunit/phpunit/phpunit"]
|
||||
|
||||
FROM ospos AS ospos_dev
|
||||
|
||||
RUN mkdir -p /app/bower_components && ln -s /app/bower_components /var/www/html/bower_components
|
||||
ARG USERID
|
||||
ARG GROUPID
|
||||
|
||||
RUN echo "Adding user uid $USERID with gid $GROUPID"
|
||||
RUN ( addgroup --gid $GROUPID ospos || true ) && ( adduser --uid $USERID --gid $GROUPID ospos )
|
||||
|
||||
RUN yes | pecl install xdebug \
|
||||
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
|
||||
&& echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/xdebug.ini \
|
||||
&& echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/xdebug.ini \
|
||||
&& echo "xdebug.remote_autostart=off" >> /usr/local/etc/php/conf.d/xdebug.ini
|
||||
|
||||
306
Gruntfile.js
306
Gruntfile.js
@@ -1,306 +0,0 @@
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
wiredep: {
|
||||
task: {
|
||||
ignorePath: '../../../public/',
|
||||
src: ['application/views/partial/header.php']
|
||||
}
|
||||
},
|
||||
bower_concat: {
|
||||
all: {
|
||||
mainFiles: {
|
||||
'bootstrap-table': [
|
||||
"dist/bootstrap-table.min.js",
|
||||
"dist/bootstrap-table.css",
|
||||
"dist/extensions/export/bootstrap-table-export.min.js",
|
||||
"dist/extensions/mobile/bootstrap-table-mobile.min.js",
|
||||
"dist/extensions/sticky-header/bootstrap-table-sticky-header.min.js",
|
||||
"dist/extensions/sticky-header/bootstrap-table-sticky-header.css"
|
||||
],
|
||||
'chartist-plugin-axistitle': [ "./dist/chartist-plugin-axistitle.min.js"]
|
||||
},
|
||||
dest: {
|
||||
'js': 'tmp/opensourcepos_bower.js',
|
||||
'css': 'tmp/opensourcepos_bower.css'
|
||||
}
|
||||
}
|
||||
},
|
||||
bowercopy: {
|
||||
options: {
|
||||
report: false
|
||||
},
|
||||
targetdistjqueryui: {
|
||||
options: {
|
||||
srcPrefix: 'public/bower_components/jquery-ui',
|
||||
destPrefix: 'public/dist'
|
||||
},
|
||||
files: {
|
||||
'jquery-ui': 'themes/base/jquery-ui.min.css'
|
||||
}
|
||||
},
|
||||
targetdistbootswatch: {
|
||||
options: {
|
||||
srcPrefix: 'public/bower_components/bootswatch',
|
||||
destPrefix: 'public/dist'
|
||||
},
|
||||
files: {
|
||||
bootswatch: '*/'
|
||||
}
|
||||
},
|
||||
targetlicense: {
|
||||
options: {
|
||||
srcPrefix: './'
|
||||
},
|
||||
files: {
|
||||
'public/license': 'LICENSE'
|
||||
}
|
||||
}
|
||||
},
|
||||
copy: {
|
||||
themes: {
|
||||
files: [
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'node_modules/bootstrap/dist/css',
|
||||
src: ['bootstrap.css', 'bootstrap.min.css'],
|
||||
dest: 'public/dist/bootswatch-5/bootstrap/',
|
||||
filter: 'isFile'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'node_modules/bootswatch/dist',
|
||||
src: ['**/bootstrap.css', '**/bootstrap.min.css'],
|
||||
dest: 'public/dist/bootswatch-5/',
|
||||
filter: 'isFile'
|
||||
}
|
||||
],
|
||||
},
|
||||
licenses: {
|
||||
files: [{
|
||||
expand: true,
|
||||
src: 'LICENSE',
|
||||
dest: 'public/license/',
|
||||
filter: 'isFile',},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'node_modules/bootstrap',
|
||||
src: 'LICENSE',
|
||||
dest: 'public/license/',
|
||||
rename: function(dest, src) { return dest + src.replace('LICENSE', 'bootstrap-5.license'); },
|
||||
filter: 'isFile'
|
||||
},
|
||||
{
|
||||
expand: true,
|
||||
cwd: 'node_modules/bootswatch',
|
||||
src: 'LICENSE',
|
||||
dest: 'public/license/',
|
||||
rename: function(dest, src) { return dest + src.replace('LICENSE', 'bootswatch-5.license'); },
|
||||
filter: 'isFile'
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
cssmin: {
|
||||
target: {
|
||||
files: {
|
||||
'public/dist/opensourcepos.min.css': ['tmp/opensourcepos_bower.css', 'public/css/*.css', '!public/css/login.css', '!public/css/login.min.css', '!public/css/invoice_email.css', '!public/css/barcode_font.css', '!public/css/darkly.css'],
|
||||
'public/css/login.min.css': ['public/css/login.css']
|
||||
}
|
||||
}
|
||||
},
|
||||
concat: {
|
||||
js: {
|
||||
options: {
|
||||
separator: ';'
|
||||
},
|
||||
files: {
|
||||
'tmp/opensourcepos.js': ['public/dist/jquery/jquery.js', 'tmp/opensourcepos_bower.js', 'public/js/*.js']
|
||||
}
|
||||
},
|
||||
sql: {
|
||||
options: {
|
||||
banner: '-- >> This file is autogenerated from tables.sql and constraints.sql. Do not modify directly << --'
|
||||
},
|
||||
files: {
|
||||
'database/database.sql': ['database/tables.sql', 'database/constraints.sql'],
|
||||
'database/migrate_phppos_dist.sql': ['database/tables.sql', 'database/phppos_migrate.sql', 'database/constraints.sql']
|
||||
}
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
options: {
|
||||
banner: '/*! opensourcepos <%= grunt.template.today("dd-mm-yyyy") %> */\n'
|
||||
},
|
||||
dist: {
|
||||
files: {
|
||||
'public/dist/opensourcepos.min.js': ['tmp/opensourcepos.js']
|
||||
}
|
||||
}
|
||||
},
|
||||
jshint: {
|
||||
files: ['Gruntfile.js', 'public/js/*.js'],
|
||||
options: {
|
||||
// options here to override JSHint defaults
|
||||
globals: {
|
||||
jQuery: true,
|
||||
console: true,
|
||||
module: true,
|
||||
document: true
|
||||
}
|
||||
}
|
||||
},
|
||||
tags: {
|
||||
css_header: {
|
||||
options: {
|
||||
scriptTemplate: '<rel type="text/css" src="{{ path }}"></rel>',
|
||||
openTag: '<!-- start css template tags -->',
|
||||
closeTag: '<!-- end css template tags -->',
|
||||
ignorePath: '../../../public/'
|
||||
},
|
||||
src: ['public/css/*.css', '!public/css/login.css', '!public/css/login.min.css', '!public/css/invoice_email.css', '!public/css/barcode_font.css', '!public/css/darkly.css'],
|
||||
dest: 'application/views/partial/header.php',
|
||||
},
|
||||
mincss_header: {
|
||||
options: {
|
||||
scriptTemplate: '<rel type="text/css" src="{{ path }}"></rel>',
|
||||
openTag: '<!-- start mincss template tags -->',
|
||||
closeTag: '<!-- end mincss template tags -->',
|
||||
ignorePath: '../../../public/'
|
||||
},
|
||||
// jquery-ui must be first or at least before opensourcepos.min.css
|
||||
src: ['public/dist/jquery-ui/*.css', 'public/dist/*.css'],
|
||||
dest: 'application/views/partial/header.php',
|
||||
},
|
||||
css_login: {
|
||||
options: {
|
||||
scriptTemplate: '<rel type="text/css" src="{{ path }}"></rel>',
|
||||
openTag: '<!-- start css template tags -->',
|
||||
closeTag: '<!-- end css template tags -->',
|
||||
ignorePath: '../../public/'
|
||||
},
|
||||
src: 'public/css/login.min.css',
|
||||
dest: 'application/views/login.php'
|
||||
},
|
||||
js: {
|
||||
options: {
|
||||
scriptTemplate: '<script type="text/javascript" src="{{ path }}"></script>',
|
||||
openTag: '<!-- start js template tags -->',
|
||||
closeTag: '<!-- end js template tags -->',
|
||||
ignorePath: '../../../public/'
|
||||
},
|
||||
src: ['public/dist/bootstrap/js/*.min.js', 'public/js/jquery*', 'public/js/*.js'],
|
||||
dest: 'application/views/partial/header.php'
|
||||
},
|
||||
minjs: {
|
||||
options: {
|
||||
scriptTemplate: '<script type="text/javascript" src="{{ path }}"></script>',
|
||||
openTag: '<!-- start minjs template tags -->',
|
||||
closeTag: '<!-- end minjs template tags -->',
|
||||
ignorePath: '../../../public/'
|
||||
},
|
||||
src: ['public/dist/*min.js'],
|
||||
dest: 'application/views/partial/header.php'
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
files: ['<%= jshint.files %>'],
|
||||
tasks: ['jshint']
|
||||
},
|
||||
cachebreaker: {
|
||||
dev: {
|
||||
options: {
|
||||
match: [ {
|
||||
'opensourcepos.min.js': 'public/dist/opensourcepos.min.js',
|
||||
'opensourcepos.min.css': 'public/dist/opensourcepos.min.css'
|
||||
} ],
|
||||
replacement: 'md5'
|
||||
},
|
||||
files: {
|
||||
src: ['application/views/partial/header.php', 'application/views/login.php']
|
||||
}
|
||||
}
|
||||
},
|
||||
clean: {
|
||||
bower: ["public/bower_components"],
|
||||
composer: ["vendor"],
|
||||
license: ['public/bower_components/**/bower.json'],
|
||||
npm: ["node_modules"]
|
||||
},
|
||||
license: {
|
||||
all: {
|
||||
// Target-specific file lists and/or options go here.
|
||||
options: {
|
||||
// Target-specific options go here.
|
||||
directory: 'public/bower_components',
|
||||
output: 'public/license/bower.LICENSES'
|
||||
}
|
||||
}
|
||||
},
|
||||
'bower-licensechecker': {
|
||||
options: {
|
||||
/*directory: 'path/to/bower',*/
|
||||
acceptable: [ 'MIT', 'BSD', 'LICENSE.md' ],
|
||||
printTotal: true,
|
||||
warn: {
|
||||
nonBower: true,
|
||||
noLicense: true,
|
||||
allGood: true,
|
||||
noGood: true
|
||||
},
|
||||
log: {
|
||||
outFile: 'public/license/.licenses',
|
||||
nonBower: true,
|
||||
noLicense: true,
|
||||
allGood: true,
|
||||
noGood: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
compress: {
|
||||
main: {
|
||||
options: {
|
||||
mode: 'tar',
|
||||
archive: 'dist/opensourcepos.tgz',
|
||||
level: 2
|
||||
},
|
||||
files: [
|
||||
{
|
||||
src: [
|
||||
'public/**',
|
||||
'vendor/**',
|
||||
'application/**',
|
||||
'!/application/tests',
|
||||
'!/public/images/menubar/png/',
|
||||
'!/public/dist/bootswatch/',
|
||||
'/public/dist/bootswatch/*/*.css',
|
||||
'!/public/dist/bootswatch-5/',
|
||||
'/public/dist/bootswatch-5/*/*.css',
|
||||
'database/**',
|
||||
'*.txt',
|
||||
'*.md',
|
||||
'LICENSE',
|
||||
'docker*',
|
||||
'docker/**',
|
||||
'Dockerfile',
|
||||
'**/.htaccess',
|
||||
'*.csv'
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
require('load-grunt-tasks')(grunt);
|
||||
grunt.loadNpmTasks('grunt-composer');
|
||||
grunt.loadNpmTasks('grunt-contrib-compress');
|
||||
|
||||
grunt.registerTask('default', ['wiredep', 'bower_concat', 'bowercopy', 'copy', 'concat', 'uglify', 'cssmin', 'tags', 'cachebreaker']);
|
||||
grunt.registerTask('update', ['composer:update', 'bower:update']);
|
||||
grunt.registerTask('genlicense', ['clean:license', 'license', 'bower-licensechecker']);
|
||||
grunt.registerTask('package', ['default', 'compress']);
|
||||
grunt.registerTask('packages', ['composer:update']);
|
||||
|
||||
};
|
||||
14
INSTALL.md
14
INSTALL.md
@@ -1,27 +1,27 @@
|
||||
## Server Requirements
|
||||
|
||||
- PHP version `7.2` to `7.4` are supported, PHP version `≤5.6` and `8.0` are NOT supported. Please note that PHP needs to have the extensions `php-gd`, `php-bcmath`, `php-intl`, `php-openssl`, `php-mbstring` and `php-curl` installed and enabled.
|
||||
- MySQL `5.5`, `5.6` and `5.7` are supported, also MariaDB replacement `10.x` is supported and might offer better performance.
|
||||
- Apache `2.2` and `2.4` are supported. Nginx should work fine too, see [wiki page here](https://github.com/opensourcepos/opensourcepos/wiki/Local-Deployment-using-LEMP).
|
||||
- PHP version `7.4` to `8.3` are supported, PHP version `≤7.3` is NOT supported. Please note that PHP needs to have the extensions `php-gd`, `php-bcmath`, `php-intl`, `php-openssl`, `php-mbstring` , `php-curl` and `php-xml` installed and enabled.
|
||||
- MySQL `5.6` and `5.7` are supported, also MariaDB replacement `10.x` is supported and might offer better performance.
|
||||
- Apache `2.4` is supported. Nginx should work fine too, see [wiki page here](https://github.com/opensourcepos/opensourcepos/wiki/Local-Deployment-using-LEMP).
|
||||
- Raspberry PI based installations proved to work, see [wiki page here](<https://github.com/opensourcepos/opensourcepos/wiki/Installing-on-Raspberry-PI---Orange-PI-(Headless-OSPOS)>).
|
||||
- For Windows based installations please read [the wiki](https://github.com/opensourcepos/opensourcepos/wiki). There are closed issues about this subject, as this topic has been covered a lot.
|
||||
|
||||
## Local install
|
||||
|
||||
First of all, if you're seeing the message `system folder missing` after launching your browser, that most likely means you have cloned the repository and have not built the project.
|
||||
First of all, if you're seeing the message `system folder missing` after launching your browser, or cannot find `database.php`, that most likely means you have cloned the repository and have not built the project. To build the project from a source commit point instead of from an official release check out [Building OSPOS](BUILD.md). Otherwise, continue with the following steps.
|
||||
|
||||
1. Download the a [pre-release for a specific branch](https://github.com/opensourcepos/opensourcepos/packages/1047637) or the latest stable [from GitHub here](https://github.com/opensourcepos/opensourcepos/releases). A repository clone will not work unless know how to build the project.
|
||||
2. Create/locate a new MySQL database to install Open Source Point of Sale into.
|
||||
3. Execute the file `database/database.sql` to create the tables needed.
|
||||
4. Unzip and upload Open Source Point of Sale files to the web-server.
|
||||
5. Open `application/config/database.php` and modify credentials to connect to your database if needed.
|
||||
6. Open `application/config/config.php` and swap the encryption key with your own.
|
||||
5. Open `app/Config/database.php` and modify credentials to connect to your database if needed.
|
||||
6. Open `app/Config/config.php` and swap the encryption key with your own.
|
||||
7. Go to your install `public` dir via the browser.
|
||||
8. Log in using
|
||||
- Username: admin
|
||||
- Password: pointofsale
|
||||
9. Enjoy!
|
||||
10. Oops, an issue? Please make sure you read the FAQ, wiki page, and you checked open and closed issues on GitHub. PHP `display_errors` is disabled by default. Create an` application/config/.env` file from the `.env.example` to enable it in a development environment.
|
||||
10. Oops, an issue? Please make sure you read the FAQ, wiki page, and you checked open and closed issues on GitHub. PHP `display_errors` is disabled by default. Create an` app/Config/.env` file from the `.env.example` to enable it in a development environment.
|
||||
|
||||
## Local install using Docker
|
||||
|
||||
|
||||
22
LICENSE
22
LICENSE
@@ -1,11 +1,11 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013-2021 jekkos
|
||||
Copyright (c) 2015-2021 FrancescoUK (aka daN4cat)
|
||||
Copyright (c) 2017-2021 Steve Ireland
|
||||
Copyright (c) 2017-2021 objecttothis
|
||||
Copyright (c) 2017-2021 odiea
|
||||
Copyright (c) 2017-2021 WebShells
|
||||
Copyright (c) 2013-2023 jekkos
|
||||
Copyright (c) 2015-2023 FrancescoUK (aka daN4cat)
|
||||
Copyright (c) 2017-2023 Steve Ireland
|
||||
Copyright (c) 2017-2023 objecttothis
|
||||
Copyright (c) 2017-2023 odiea
|
||||
Copyright (c) 2017-2023 WebShells
|
||||
Copyright (c) 2020-2021 Andriux1990
|
||||
Copyright (c) 2021 BudsieBuds
|
||||
Copyright (c) 2019 Loyd Jayme (aka loydjayme25)
|
||||
@@ -19,7 +19,7 @@ Copyright (c) 2017 asadjaved63
|
||||
Copyright (c) 2016-2017 Ramkrishna Mondal (aka RamkrishnaMondal)
|
||||
Copyright (c) 2016-2017 Jorge Colmenarez (aka jlctmaster), frontuari.com
|
||||
Copyright (c) 2016 Rinaldy@dbarber (aka rnld26)
|
||||
Copyright (c) 2015 Aamir Shahzad (aka asakpke), RoshanTech.com
|
||||
Copyright (c) 2015-2022 Aamir Shahzad (aka asakpke), RoshanTech, eSite.pk
|
||||
Copyright (c) 2015 Toni Haryanto (aka yllumi)
|
||||
Copyright (c) 2013 Rob Garrison
|
||||
Copyright (c) 2013 Parq
|
||||
@@ -34,16 +34,16 @@ 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 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.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
Additionally, you cannot claim copyright or ownership of the Software.
|
||||
|
||||
|
||||
42
README.md
42
README.md
@@ -1,4 +1,4 @@
|
||||
<p align="center"><img src="branding/emblem.svg" alt="Open Source Point of Sale Logo" width="auto" height="200"></p>
|
||||
<p align="center"><img src="https://raw.githubusercontent.com/opensourcepos/opensourcepos/master/branding/emblem.svg" alt="Open Source Point of Sale Logo" width="auto" height="200"></p>
|
||||
<h3 align="center">Open Source Point of Sale</h3>
|
||||
|
||||
<p align="center">
|
||||
@@ -8,17 +8,17 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/opensourcepos/opensourcepos" target="_blank"><img src="https://travis-ci.com/opensourcepos/opensourcepos.svg?branch=master" alt="Build Status"></a>
|
||||
<a href="https://gitter.im/opensourcepos?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge" target="_blank"><img src="https://badges.gitter.im/jekkos/opensourcepos.svg" alt="Join the chat at https://gitter.im/opensourcepos"></a>
|
||||
<a href="https://badge.fury.io/gh/jekkos%2Fopensourcepos" target="_blank"><img src="https://badge.fury.io/gh/jekkos%2Fopensourcepos.svg" alt="Project Version"></a>
|
||||
<a href="http://translate.opensourcepos.org/engage/opensourcepos/?utm_source=widget" target="_blank"><img src="http://translate.opensourcepos.org/widgets/opensourcepos/-/svg-badge.svg" alt="Translation Status"></a>
|
||||
<a href="https://app.travis-ci.com/opensourcepos/opensourcepos" target="_blank"><img src="https://api.travis-ci.com/opensourcepos/opensourcepos.svg?branch=master" alt="Build Status"></a>
|
||||
<a href="https://app.gitter.im/#/room/#opensourcepos_Lobby:gitter.im?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge" target="_blank"><img src="https://badges.gitter.im/jekkos/opensourcepos.svg" alt="Join the chat at https://app.gitter.im"></a>
|
||||
<a href="https://badge.fury.io/gh/opensourcepos%2Fopensourcepos" target="_blank"><img src="https://badge.fury.io/gh/opensourcepos%2Fopensourcepos.svg" alt="Project Version"></a>
|
||||
<a href="https://translate.opensourcepos.org/engage/opensourcepos/?utm_source=widget" target="_blank"><img src="https://translate.opensourcepos.org/widgets/opensourcepos/-/svg-badge.svg" alt="Translation Status"></a>
|
||||
</p>
|
||||
|
||||
## 👋 Introduction
|
||||
|
||||
Open Source Point of Sale is a web-based point of sale system. The application is written in PHP, it uses MySQL (or MariaDB) as data storage back-end and has a simple but intuitive user interface.
|
||||
Open Source Point of Sale is a web-based point of sale system. The application is written in PHP, uses MySQL (or MariaDB) as the data storage back-end, and has a simple but intuitive user interface.
|
||||
|
||||
The latest `3.x` version is a complete overhaul of the original software. It uses CodeIgniter 3 as a framework and is based on Bootstrap 3 using Bootswatch themes. Along with improved functionality and security.
|
||||
The latest `3.4` version is a complete overhaul of the original software. It uses CodeIgniter 4 as a framework and is based on Bootstrap 3 using Bootswatch themes. Along with improved functionality and security.
|
||||
|
||||
The features include:
|
||||
|
||||
@@ -40,8 +40,8 @@ The features include:
|
||||
- Messaging (SMS)
|
||||
- Multilanguage
|
||||
- Selectable Bootstrap based UI theme with Bootswatch
|
||||
- Mailchimp integration
|
||||
- Optional Google reCAPTCHA to protect login page from brute force attacks
|
||||
- MailChimp integration
|
||||
- Optional Google reCAPTCHA to protect the login page from brute force attacks
|
||||
- GDPR ready
|
||||
|
||||
## 🧪 Live Demo
|
||||
@@ -70,7 +70,7 @@ For more information and recommendations on support hardware, like receipt print
|
||||
|
||||
## ✨ Contributing
|
||||
|
||||
Everyone is more than welcome to help us improve this project. If you think you've got something to help us go forward, feel free to open a [pull request]().
|
||||
Everyone is more than welcome to help us improve this project. If you think you've got something to help us go forward, feel free to open a [pull request]() or join the conversation on [Element](https://app.gitter.im/#/room/#opensourcepos_Lobby:gitter.im).
|
||||
|
||||
Want to help translate Open Source Point of Sale in your language? You can find [our Weblate here](https://translate.opensourcepos.org), sign up, and start translating. You can subscribe to different languages to receive a notification once a new string is added or needs updating. Have a look at our [guidelines](https://github.com/opensourcepos/opensourcepos/wiki/Adding-translations) below to help you get started.
|
||||
|
||||
@@ -82,7 +82,7 @@ Before creating a new issue, you'll need copy and include the info under the `Sy
|
||||
|
||||
If you're reporting a potential security issue, please refer to our security policy found in the [SECURITY.md](SECURITY.md) file.
|
||||
|
||||
NOTE: If you're running non-release code, please make sure you always run the latest database upgrade script and you download the latest master code.
|
||||
NOTE: If you're running non-release code, please make sure you always run the latest database upgrade script and download the latest master code.
|
||||
|
||||
## 📖 FAQ
|
||||
|
||||
@@ -90,7 +90,7 @@ NOTE: If you're running non-release code, please make sure you always run the la
|
||||
|
||||
- If at login time you read `The installation is not correct, check your php.ini file.`, please check the error_log in `public` folder to understand what's wrong and make sure you read the [INSTALL.md](INSTALL.md). To know how to enable `error_log`, please read the comment in [issue #1770](https://github.com/opensourcepos/opensourcepos/issues/1770#issuecomment-355177943).
|
||||
|
||||
- If you installed your OSPOS under a web server subdir, please edit `public/.htaccess` and go to the lines with the comments `if in web root` or `if in subdir`, uncomment one and replace `<OSPOS path>` with your path and follow the instruction on the second comment line. If you face more issues, please read [issue #920](https://github.com/opensourcepos/opensourcepos/issues/920) for more information.
|
||||
- If you installed your OSPOS under a web server subdir, please edit `public/.htaccess` and go to the lines with the comments `if in web root` or `if in subdir`, uncomment one and replace `<OSPOS path>` with your path, and follow the instruction on the second comment line. If you face more issues, please read [issue #920](https://github.com/opensourcepos/opensourcepos/issues/920) for more information.
|
||||
|
||||
- Apache server configurations are SysAdmin issues and not strictly related to OSPOS. Please make sure you can show a "Hello world" HTML page before pointing to OSPOS public directory. Make sure `.htaccess` is correctly configured.
|
||||
|
||||
@@ -98,11 +98,11 @@ NOTE: If you're running non-release code, please make sure you always run the la
|
||||
|
||||
- If you install OSPOS in Docker behind a proxy that performs `ssloffloading`, you can enable the URL generated to be HTTPS instead of HTTP, by activating the environment variable `FORCE_HTTPS = 1`.
|
||||
|
||||
- If you install OSPOS behind a proxy and OSPOS constantly drops your session, consider whitelisting the proxy IP address by setting `$config['proxy_ips'] = '<proxy ip>';` in the [main PHP config file](https://github.com/opensourcepos/opensourcepos/blob/master/application/config/config.php). In extreme instances, changing `$config['sess_match_ip'] = true;` to `FALSE` may also help.
|
||||
|
||||
- If you have suhosin installed and face an issue with CSRF, please make sure you read [issue #1492](https://github.com/opensourcepos/opensourcepos/issues/1492).
|
||||
|
||||
- PHP 8.0 is not currently supported, see [issue #3051](https://github.com/opensourcepos/opensourcepos/issues/3051).
|
||||
|
||||
- PHP 5.5 and 5.6 are no longer supported due to the fact that they have been deprecated and not safe to use from security point of view.
|
||||
- PHP `≥ 8.1` is required to run this app.
|
||||
|
||||
## 🏃 Keep the Machine Running
|
||||
|
||||
@@ -111,13 +111,13 @@ If you like our project, please consider buying us a coffee through the button b
|
||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MUN6AEG7NY6H8)\
|
||||
Or refer to the [FUNDING.yml](.github/FUNDING.yml) file.
|
||||
|
||||
If you choose to deploy OSPOS in the cloud, you can contribute to the project by using DigitalOcean and signing up through our referral link. You'll receive a [free $100, 60-day credit](https://m.do.co/c/ac38c262507b) if you run OSPOS in a DigitalOcean droplet through [our referral link](https://m.do.co/c/ac38c262507b).
|
||||
If you choose to deploy OSPOS in the cloud, you can contribute to the project by using DigitalOcean and signing up through our referral link. You'll receive a [free $200, 60-day credit](https://m.do.co/c/ac38c262507b) if you run OSPOS in a DigitalOcean droplet through [our referral link](https://m.do.co/c/ac38c262507b).
|
||||
|
||||
## 📄 License
|
||||
|
||||
Open Source Point of Sale is licensed under MIT terms with an important addition:
|
||||
|
||||
The footer signature "© 2010 - _current year_ · opensourcepos.org · 3.x.x - _hash_" including the version, hash and link our website MUST BE RETAINED, MUST BE VISIBLE IN EVERY PAGE and CANNOT BE MODIFIED.
|
||||
The footer signature "© 2010 - _current year_ · opensourcepos.org · 3.x.x - _hash_" including the version, hash and link to our website MUST BE RETAINED, MUST BE VISIBLE IN EVERY PAGE and CANNOT BE MODIFIED.
|
||||
|
||||
Also worth noting:
|
||||
|
||||
@@ -125,13 +125,13 @@ _The above copyright notice and this permission notice shall be included in all
|
||||
|
||||
For more details please read the [LICENSE](LICENSE) file.
|
||||
|
||||
It's important to understand that although you are free to use the application the copyright has to stay and the license agreement applies in all cases. Therefore any actions like:
|
||||
It's important to understand that although you are free to use the application, the copyright has to stay and the license agreement applies in all cases. Therefore, any actions like:
|
||||
|
||||
- Removing LICENSE and/or any license files is prohibited
|
||||
- Authoring the footer notice replacing it with your own or even worse claiming the copyright is absolutely prohibited
|
||||
- Claiming full ownership of the code is prohibited
|
||||
|
||||
In short, you are free to use the application but you cannot claim any property on it.
|
||||
In short, you are free to use the application, but you cannot claim any property on it.
|
||||
|
||||
Any person or company found breaching the license agreement might find a bunch of monkeys at the door ready to destroy their servers.
|
||||
|
||||
@@ -139,5 +139,5 @@ Any person or company found breaching the license agreement might find a bunch o
|
||||
|
||||
| <div align="center">JetBrains</div> | <div align="center">Travis CI</div> |
|
||||
|--- | --- |
|
||||
| <div align="center"><img src="https://upload.wikimedia.org/wikipedia/commons/9/9c/IntelliJ_IDEA_Icon.svg" alt="IntelliJ IDEA Logo" height="50"></div> | <div align="center"><img src="https://secrethub.io/img/travis-ci.svg" alt="Travis CI Logo" height="50"></div> |
|
||||
| Many thanks to [JetBrains](https://www.jetbrains.com/) for providing a free license of [IntelliJ IDEA](https://www.jetbrains.com/idea/) to kindly support the development of OSPOS. | Many thanks to [Travis CI](https://travis-ci.org) for providing a free continuous integration service for open source projects. |
|
||||
| <div align="center"><a href="https://www.jetbrains.com/idea/" target="_blank"><img src="https://github.com/opensourcepos/opensourcepos/assets/12870258/187f9bbe-4484-475c-9b58-5e5d5f931f09" alt="IntelliJ IDEA Logo" height="50"></a></div> | <div align="center"><a href="https://www.travis-ci.com/" target="_blank"><img src="https://github.com/opensourcepos/opensourcepos/assets/12870258/71cc2b44-83af-4510-a543-6358285f43c6" alt="Travis CI Logo" height="50"></a></div> |
|
||||
| Many thanks to [JetBrains](https://www.jetbrains.com/) for providing a free license of [IntelliJ IDEA](https://www.jetbrains.com/idea/) to kindly support the development of OSPOS. | Many thanks to [Travis CI](https://www.travis-ci.com/) for providing a free continuous integration service for open source projects. |
|
||||
|
||||
6
app/.htaccess
Normal file
6
app/.htaccess
Normal file
@@ -0,0 +1,6 @@
|
||||
<IfModule authz_core_module>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
<IfModule !authz_core_module>
|
||||
Deny from all
|
||||
</IfModule>
|
||||
15
app/Common.php
Normal file
15
app/Common.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The goal of this file is to allow developers a location
|
||||
* where they can overwrite core procedural functions and
|
||||
* replace them with their own. This file is loaded during
|
||||
* the bootstrap process and is called during the framework's
|
||||
* execution.
|
||||
*
|
||||
* This can be looked at as a `master helper` file that is
|
||||
* loaded early on, and may also contain additional functions
|
||||
* that you'd like to use throughout your entire application
|
||||
*
|
||||
* @see: https://codeigniter.com/user_guide/extending/common.html
|
||||
*/
|
||||
290
app/Config/App.php
Normal file
290
app/Config/App.php
Normal file
@@ -0,0 +1,290 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Session\Handlers\DatabaseHandler;
|
||||
|
||||
class App extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* This is the code version of the Open Source Point of Sale you're running.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public string $application_version = '3.4.0-dev';
|
||||
|
||||
/**
|
||||
* This is the commit hash for the version you are currently using.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public string $commit_sha1 = 'dev';
|
||||
|
||||
/**
|
||||
* Logs are stored in writable/logs
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public bool $db_log_enabled = false;
|
||||
|
||||
/**
|
||||
* DB Query Log only long-running queries
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public bool $db_log_only_long = false;
|
||||
|
||||
/**
|
||||
* Defines whether to require/reroute to HTTPS
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public bool $https_on; //Set in the constructor
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Base Site URL
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* URL to your CodeIgniter root. Typically, this will be your base URL,
|
||||
* WITH a trailing slash:
|
||||
*
|
||||
* E.g., http://example.com/
|
||||
*/
|
||||
public string $baseURL; //Defined in the constructor
|
||||
|
||||
/**
|
||||
* Allowed Hostnames in the Site URL other than the hostname in the baseURL.
|
||||
* If you want to accept multiple Hostnames, set this.
|
||||
*
|
||||
* E.g.,
|
||||
* When your site URL ($baseURL) is 'http://example.com/', and your site
|
||||
* also accepts 'http://media.example.com/' and 'http://accounts.example.com/':
|
||||
* ['media.example.com', 'accounts.example.com']
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $allowedHostnames = [];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Index File
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Typically, this will be your `index.php` file, unless you've renamed it to
|
||||
* something else. If you have configured your web server to remove this file
|
||||
* from your site URIs, set this variable to an empty string.
|
||||
*/
|
||||
public string $indexPage = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* URI PROTOCOL
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This item determines which server global should be used to retrieve the
|
||||
* URI string. The default setting of 'REQUEST_URI' works for most servers.
|
||||
* If your links do not seem to work, try one of the other delicious flavors:
|
||||
*
|
||||
* 'REQUEST_URI': Uses $_SERVER['REQUEST_URI']
|
||||
* 'QUERY_STRING': Uses $_SERVER['QUERY_STRING']
|
||||
* 'PATH_INFO': Uses $_SERVER['PATH_INFO']
|
||||
*
|
||||
* WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
|
||||
*/
|
||||
public string $uriProtocol = 'REQUEST_URI';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Allowed URL Characters
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This lets you specify which characters are permitted within your URLs.
|
||||
| When someone tries to submit a URL with disallowed characters they will
|
||||
| get a warning message.
|
||||
|
|
||||
| As a security measure you are STRONGLY encouraged to restrict URLs to
|
||||
| as few characters as possible.
|
||||
|
|
||||
| By default, only these are allowed: `a-z 0-9~%.:_-`
|
||||
|
|
||||
| Set an empty string to allow all characters -- but only if you are insane.
|
||||
|
|
||||
| The configured value is actually a regular expression character group
|
||||
| and it will be used as: '/\A[<permittedURIChars>]+\z/iu'
|
||||
|
|
||||
| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
|
||||
|
|
||||
*/
|
||||
public string $permittedURIChars = 'a-z 0-9~%.:_\-';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Default Locale
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The Locale roughly represents the language and location that your visitor
|
||||
* is viewing the site from. It affects the language strings and other
|
||||
* strings (like currency markers, numbers, etc), that your program
|
||||
* should run under for this request.
|
||||
*/
|
||||
public string $defaultLocale = 'en';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Negotiate Locale
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If true, the current Request object will automatically determine the
|
||||
* language to use based on the value of the Accept-Language header.
|
||||
*
|
||||
* If false, no automatic detection will be performed.
|
||||
*/
|
||||
public bool $negotiateLocale = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Supported Locales
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If $negotiateLocale is true, this array lists the locales supported
|
||||
* by the application in descending order of priority. If no match is
|
||||
* found, the first locale will be used.
|
||||
*
|
||||
* IncomingRequest::setLocale() also uses this list.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $supportedLocales = [
|
||||
'ar-EG',
|
||||
'ar-LB',
|
||||
'az',
|
||||
'bg',
|
||||
'bs',
|
||||
'cs',
|
||||
'da',
|
||||
'de-CH',
|
||||
'de-DE',
|
||||
'el',
|
||||
'en',
|
||||
'en-GB',
|
||||
'es-ES',
|
||||
'es-MX',
|
||||
'fa',
|
||||
'fr',
|
||||
'he',
|
||||
'hr-HR',
|
||||
'hu',
|
||||
'hy',
|
||||
'id',
|
||||
'it',
|
||||
'km',
|
||||
'lo',
|
||||
'ml',
|
||||
'nb',
|
||||
'nl-BE',
|
||||
'nl-NL',
|
||||
'pl',
|
||||
'pt-BR',
|
||||
'ro',
|
||||
'ru',
|
||||
'sv',
|
||||
'ta',
|
||||
'th',
|
||||
'tl',
|
||||
'tr',
|
||||
'uk',
|
||||
'ur',
|
||||
'vi',
|
||||
'zh-Hans',
|
||||
'zh-Hant',
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Application Timezone
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The default timezone that will be used in your application to display
|
||||
* dates with the date helper, and can be retrieved through app_timezone()
|
||||
*
|
||||
* @see https://www.php.net/manual/en/timezones.php for list of timezones
|
||||
* supported by PHP.
|
||||
*/
|
||||
public string $appTimezone = 'UTC';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Default Character Set
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This determines which character set is used by default in various methods
|
||||
* that require a character set to be provided.
|
||||
*
|
||||
* @see http://php.net/htmlspecialchars for a list of supported charsets.
|
||||
*/
|
||||
public string $charset = 'UTF-8';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Force Global Secure Requests
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If true, this will force every request made to this application to be
|
||||
* made via a secure connection (HTTPS). If the incoming request is not
|
||||
* secure, the user will be redirected to a secure version of the page
|
||||
* and the HTTP Strict Transport Security (HSTS) header will be set.
|
||||
*/
|
||||
public bool $forceGlobalSecureRequests = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Reverse Proxy IPs
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If your server is behind a reverse proxy, you must whitelist the proxy
|
||||
* IP addresses from which CodeIgniter should trust headers such as
|
||||
* X-Forwarded-For or Client-IP in order to properly identify
|
||||
* the visitor's IP address.
|
||||
*
|
||||
* You need to set a proxy IP address or IP address with subnets and
|
||||
* the HTTP header for the client IP address.
|
||||
*
|
||||
* Here are some examples:
|
||||
* [
|
||||
* '10.0.1.200' => 'X-Forwarded-For',
|
||||
* '192.168.5.0/24' => 'X-Real-IP',
|
||||
* ]
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $proxyIPs = [];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Content Security Policy
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Enables the Response's Content Secure Policy to restrict the sources that
|
||||
* can be used for images, scripts, CSS files, audio, video, etc. If enabled,
|
||||
* the Response object will populate default values for the policy from the
|
||||
* `ContentSecurityPolicy.php` file. Controllers can always add to those
|
||||
* restrictions at run time.
|
||||
*
|
||||
* For a better understanding of CSP, see these documents:
|
||||
*
|
||||
* @see http://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
||||
* @see http://www.w3.org/TR/CSP/
|
||||
*/
|
||||
public bool $CSPEnabled = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->https_on = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_ENV['FORCE_HTTPS']) && $_ENV['FORCE_HTTPS'] == 'true');
|
||||
$this->baseURL = $this->https_on ? 'https' : 'http';
|
||||
$this->baseURL .= '://' . ((isset($_SERVER['HTTP_HOST'])) ? $_SERVER['HTTP_HOST'] : 'localhost') . '/';
|
||||
$this->baseURL .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
|
||||
}
|
||||
}
|
||||
210
app/Config/Autoload.php
Normal file
210
app/Config/Autoload.php
Normal file
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\AutoloadConfig;
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* AUTOLOADER CONFIGURATION
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* This file defines the namespaces and class maps so the Autoloader
|
||||
* can find the files as needed.
|
||||
*
|
||||
* NOTE: If you use an identical key in $psr4 or $classmap, then
|
||||
* the values in this file will overwrite the framework's values.
|
||||
*
|
||||
* NOTE: This class is required prior to Autoloader instantiation,
|
||||
* and does not extend BaseConfig.
|
||||
*
|
||||
* @immutable
|
||||
*/
|
||||
class Autoload extends AutoloadConfig
|
||||
{
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Namespaces
|
||||
* -------------------------------------------------------------------
|
||||
* This maps the locations of any namespaces in your application to
|
||||
* their location on the file system. These are used by the autoloader
|
||||
* to locate files the first time they have been instantiated.
|
||||
*
|
||||
* The 'Config' (APPPATH . 'Config') and 'CodeIgniter' (SYSTEMPATH) are
|
||||
* already mapped for you.
|
||||
*
|
||||
* You may change the name of the 'App' namespace if you wish,
|
||||
* but this should be done prior to creating any namespaced classes,
|
||||
* else you will need to modify all of those classes for this to work.
|
||||
*
|
||||
* @var array<string, list<string>|string>
|
||||
*/
|
||||
public $psr4 = [
|
||||
APP_NAMESPACE => APPPATH,
|
||||
'Config' => APPPATH . 'Config',
|
||||
'dompdf' => APPPATH . 'ThirdParty/dompdf/src'
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Class Map
|
||||
* -------------------------------------------------------------------
|
||||
* The class map provides a map of class names and their exact
|
||||
* location on the drive. Classes loaded in this manner will have
|
||||
* slightly faster performance because they will not have to be
|
||||
* searched for within one or more directories as they would if they
|
||||
* were being autoloaded through a namespace.
|
||||
*
|
||||
* Prototype:
|
||||
* $classmap = [
|
||||
* 'MyClass' => '/path/to/class/file.php'
|
||||
* ];
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public $classmap = [
|
||||
//Controllers
|
||||
'Attributes' => '/App/Controllers/Attributes.php',
|
||||
'Cashups' => '/App/Controllers/Cashups.php',
|
||||
'Config' => '/App/Controllers/Config.php',
|
||||
'Customers' => '/App/Controllers/Customers.php',
|
||||
'Employees' => '/App/Controllers/Employees.php',
|
||||
'Expenses' => '/App/Controllers/Expenses.php',
|
||||
'Expenses_categories' => '/App/Controllers/Expenses_categories.php',
|
||||
'Giftcards' => '/App/Controllers/Giftcards.php',
|
||||
'Home' => '/App/Controllers/Home.php',
|
||||
'Item_kits' => '/App/Controllers/Item_kits.php',
|
||||
'Items' => '/App/Controllers/Items.php',
|
||||
'Login' => '/App/Controllers/Login.php',
|
||||
'Messages' => '/App/Controllers/Messages.php',
|
||||
'No_access' => '/App/Controllers/No_access.php',
|
||||
'Office' => '/App/Controllers/Office.php',
|
||||
'Persons' => '/App/Controllers/Persons.php',
|
||||
'Receivings' => '/App/Controllers/Receivings.php',
|
||||
'Reports' => '/App/Controllers/Reports.php',
|
||||
'Sales' => '/App/Controllers/Sales.php',
|
||||
'Secure_Controller' => '/App/Controllers/Secure_Controller.php',
|
||||
'Suppliers' => '/App/Controllers/Suppliers.php',
|
||||
'Tax_categories' => '/App/Controllers/Tax_categories.php',
|
||||
'Tax_codes' => '/App/Controllers/Tax_codes.php',
|
||||
'Tax_jurisdictions' => '/App/Controllers/Tax_jurisdictions.php',
|
||||
'Taxes' => '/App/Controllers/Taxes.php',
|
||||
|
||||
//Models
|
||||
'Appconfig' => '/App/Models/Appconfig.php',
|
||||
'Attribute' => '/App/Models/Attribute.php',
|
||||
'Cashup' => '/App/Models/Cashup.php',
|
||||
'Customer' => '/App/Models/Customer.php',
|
||||
'Customer_rewards' => '/App/Models/Customer_rewards.php',
|
||||
'Dinner_table' => '/App/Models/Dinner_table.php',
|
||||
'Employee' => '/App/Models/Employee.php',
|
||||
'Expense' => '/App/Models/Expense.php',
|
||||
'Expense_category' => '/App/Models/Expense_category.php',
|
||||
'Giftcard' => '/App/Models/Giftcard.php',
|
||||
'Inventory' => '/App/Models/Inventory.php',
|
||||
'Item_kit' => '/App/Models/Item_kit.php',
|
||||
'Item_kit_items' => '/App/Models/Item_kit_items.php',
|
||||
'Item_quantity' => '/App/Models/Item_quantity.php',
|
||||
'Item_taxes' => '/App/Models/Item_taxes.php',
|
||||
'Module' => '/App/Models/Module.php',
|
||||
'Person' => '/App/Models/Person.php',
|
||||
'Receiving' => '/App/Models/Receiving.php',
|
||||
'Rewards' => '/App/Models/Rewards.php',
|
||||
'Sale' => '/App/Models/Sale.php',
|
||||
'Stock_location' => '/App/Models/Stock_location.php',
|
||||
'Supplier' => '/App/Models/Supplier.php',
|
||||
'Tax' => '/App/Models/Tax.php',
|
||||
'Tax_category' => '/App/Models/Tax_category.php',
|
||||
'Tax_code' => '/App/Models/Tax_code.php',
|
||||
'Tax_jurisdiction' => '/App/Models/Tax_jurisdiction.php',
|
||||
|
||||
//Reports
|
||||
'Report' => '/App/Models/Reports/Report.php',
|
||||
'Detailed_receiving' => '/App/Models/Reports/Detailed_receiving.php',
|
||||
'Detailed_sales' => '/App/Models/Reports/Detailed_sales.php',
|
||||
'Inventory_low' => '/App/Models/Reports/Inventory_low.php',
|
||||
'Inventory_summary' => '/App/Models/Reports/Inventory_summary.php',
|
||||
'Specific_customer' => '/App/Models/Reports/Specific_customer.php',
|
||||
'Specific_discount' => '/App/Models/Reports/Specific_discount.php',
|
||||
'Specific_employee' => '/App/Models/Reports/Specific_employee.php',
|
||||
'Specific_supplier' => '/App/Models/Reports/Specific_supplier.php',
|
||||
'Summary_categories' => '/App/Models/Reports/Summary_categories.php',
|
||||
'Summary_customers' => '/App/Models/Reports/Summary_customers.php',
|
||||
'Summary_discounts' => '/App/Models/Reports/Summary_discounts.php',
|
||||
'Summary_employees' => '/App/Models/Reports/Summary_employees.php',
|
||||
'Summary_expenses_categories' => '/App/Models/Reports/Summary_expenses_categories.php',
|
||||
'Summary_items' => '/App/Models/Reports/Summary_items.php',
|
||||
'Summary_payments' => '/App/Models/Reports/Summary_payments.php',
|
||||
'Summary_report' => '/App/Models/Reports/Summary_report.php',
|
||||
'Summary_sales' => '/App/Models/Reports/Summary_sales.php',
|
||||
'Summary_sales_taxes' => '/App/Models/Reports/Summary_sales_taxes.php',
|
||||
'Summary_suppliers' => '/App/Models/Reports/Summary_suppliers.php',
|
||||
'Summary_taxes' => '/App/Models/Reports/Summary_taxes.php',
|
||||
|
||||
//Tokens
|
||||
'Token' => '/App/Models/Tokens/Token.php',
|
||||
'Token_barcode_ean' => '/App/Models/Tokens/Token_barcode_ean.php',
|
||||
'Token_barcode_price' => '/App/Models/Tokens/Token_barcode_price.php',
|
||||
'Token_barcode_weight' => '/App/Models/Tokens/Token_barcode_weight.php',
|
||||
'Token_customer' => '/App/Models/Tokens/Token_customer.php',
|
||||
'Token_invoice_count' => '/App/Models/Tokens/Token_invoice_count.php',
|
||||
'Token_invoice_sequence' => '/App/Models/Tokens/Token_invoice_sequence.php',
|
||||
'Token_quote_sequence' => '/App/Models/Tokens/Token_quote_sequence.php',
|
||||
'Token_suspended_invoice_count' => '/App/Models/Tokens/Token_suspended_invoice_count.php',
|
||||
'Token_work_order_sequence' => '/App/Models/Tokens/Token_work_order_sequence.php',
|
||||
'Token_year_invoice_count' => '/App/Models/Tokens/Token_year_invoice_count.php',
|
||||
'Token_year_quote_count' => '/App/Models/Tokens/Token_year_quote_count.php',
|
||||
|
||||
//Libraries
|
||||
'Barcode_lib' => '/App/Libraries/Barcode_lib.php',
|
||||
'Email_lib' => '/App/Libraries/Email_lib.php',
|
||||
'Item_lib' => '/App/Libraries/Item_lib.php',
|
||||
'Mailchimp_lib' => '/App/Libraries/Mailchimp_lib.php',
|
||||
'MY_Email' => '/App/Libraries/MY_Email.php',
|
||||
'MY_Migration' => '/App/Libraries/MY_Migration.php',
|
||||
'Receving_lib' => '/App/Libraries/Receiving_lib.php',
|
||||
'Sale_lib' => '/App/Libraries/Sale_lib.php',
|
||||
'Sms_lib' => '/App/Libraries/Sms_lib.php',
|
||||
'Tax_lib' => '/App/Libraries/Tax_lib.php',
|
||||
'Token_lib' => '/App/Libraries/Token_lib.php',
|
||||
|
||||
//Miscellaneous
|
||||
'Rounding_mode' => '/App/Models/Enums/Rounding_mode.php'
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Files
|
||||
* -------------------------------------------------------------------
|
||||
* The files array provides a list of paths to __non-class__ files
|
||||
* that will be autoloaded. This can be useful for bootstrap operations
|
||||
* or for loading functions.
|
||||
*
|
||||
* Prototype:
|
||||
* $files = [
|
||||
* '/path/to/my/file.php',
|
||||
* ];
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public $files = [];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Helpers
|
||||
* -------------------------------------------------------------------
|
||||
* Prototype:
|
||||
* $helpers = [
|
||||
* 'form',
|
||||
* ];
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public $helpers = [
|
||||
'form',
|
||||
'cookie',
|
||||
'tabular',
|
||||
'locale',
|
||||
'security'
|
||||
];
|
||||
}
|
||||
34
app/Config/Boot/development.php
Normal file
34
app/Config/Boot/development.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ERROR DISPLAY
|
||||
|--------------------------------------------------------------------------
|
||||
| In development, we want to show as many errors as possible to help
|
||||
| make sure they don't make it to production. And save us hours of
|
||||
| painful debugging.
|
||||
|
|
||||
| If you set 'display_errors' to '1', CI4's detailed error report will show.
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG BACKTRACES
|
||||
|--------------------------------------------------------------------------
|
||||
| If true, this constant will tell the error screens to display debug
|
||||
| backtraces along with the other error information. If you would
|
||||
| prefer to not see this, set this value to false.
|
||||
*/
|
||||
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG MODE
|
||||
|--------------------------------------------------------------------------
|
||||
| Debug mode is an experimental flag that can allow changes throughout
|
||||
| the system. This will control whether Kint is loaded, and a few other
|
||||
| items. It can always be used within your own application too.
|
||||
*/
|
||||
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
||||
25
app/Config/Boot/production.php
Normal file
25
app/Config/Boot/production.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ERROR DISPLAY
|
||||
|--------------------------------------------------------------------------
|
||||
| Don't show ANY in production environments. Instead, let the system catch
|
||||
| it and display a generic error message.
|
||||
|
|
||||
| If you set 'display_errors' to '1', CI4's detailed error report will show.
|
||||
*/
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
// If you want to suppress more types of errors.
|
||||
// error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
|
||||
ini_set('display_errors', '0');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG MODE
|
||||
|--------------------------------------------------------------------------
|
||||
| Debug mode is an experimental flag that can allow changes throughout
|
||||
| the system. It's not widely used currently, and may not survive
|
||||
| release of the framework.
|
||||
*/
|
||||
defined('CI_DEBUG') || define('CI_DEBUG', false);
|
||||
38
app/Config/Boot/testing.php
Normal file
38
app/Config/Boot/testing.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* The environment testing is reserved for PHPUnit testing. It has special
|
||||
* conditions built into the framework at various places to assist with that.
|
||||
* You can’t use it for your development.
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| ERROR DISPLAY
|
||||
|--------------------------------------------------------------------------
|
||||
| In development, we want to show as many errors as possible to help
|
||||
| make sure they don't make it to production. And save us hours of
|
||||
| painful debugging.
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', '1');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG BACKTRACES
|
||||
|--------------------------------------------------------------------------
|
||||
| If true, this constant will tell the error screens to display debug
|
||||
| backtraces along with the other error information. If you would
|
||||
| prefer to not see this, set this value to false.
|
||||
*/
|
||||
defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| DEBUG MODE
|
||||
|--------------------------------------------------------------------------
|
||||
| Debug mode is an experimental flag that can allow changes throughout
|
||||
| the system. It's not widely used currently, and may not survive
|
||||
| release of the framework.
|
||||
*/
|
||||
defined('CI_DEBUG') || define('CI_DEBUG', true);
|
||||
20
app/Config/CURLRequest.php
Normal file
20
app/Config/CURLRequest.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class CURLRequest extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CURLRequest Share Options
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Whether share options between requests or not.
|
||||
*
|
||||
* If true, all the options won't be reset between requests.
|
||||
* It may cause an error request with unnecessary headers.
|
||||
*/
|
||||
public bool $shareOptions = false;
|
||||
}
|
||||
171
app/Config/Cache.php
Normal file
171
app/Config/Cache.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Cache\CacheInterface;
|
||||
use CodeIgniter\Cache\Handlers\DummyHandler;
|
||||
use CodeIgniter\Cache\Handlers\FileHandler;
|
||||
use CodeIgniter\Cache\Handlers\MemcachedHandler;
|
||||
use CodeIgniter\Cache\Handlers\PredisHandler;
|
||||
use CodeIgniter\Cache\Handlers\RedisHandler;
|
||||
use CodeIgniter\Cache\Handlers\WincacheHandler;
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Cache extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Primary Handler
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The name of the preferred handler that should be used. If for some reason
|
||||
* it is not available, the $backupHandler will be used in its place.
|
||||
*/
|
||||
public string $handler = 'file';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Backup Handler
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The name of the handler that will be used in case the first one is
|
||||
* unreachable. Often, 'file' is used here since the filesystem is
|
||||
* always available, though that's not always practical for the app.
|
||||
*/
|
||||
public string $backupHandler = 'dummy';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cache Directory Path
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The path to where cache files should be stored, if using a file-based
|
||||
* system.
|
||||
*
|
||||
* @deprecated Use the driver-specific variant under $file
|
||||
*/
|
||||
public string $storePath = WRITEPATH . 'cache/';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Key Prefix
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This string is added to all cache item names to help avoid collisions
|
||||
* if you run multiple applications with the same cache engine.
|
||||
*/
|
||||
public string $prefix = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Default TTL
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The default number of seconds to save items when none is specified.
|
||||
*
|
||||
* WARNING: This is not used by framework handlers where 60 seconds is
|
||||
* hard-coded, but may be useful to projects and modules. This will replace
|
||||
* the hard-coded value in a future release.
|
||||
*/
|
||||
public int $ttl = 300;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Reserved Characters
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* A string of reserved characters that will not be allowed in keys or tags.
|
||||
* Strings that violate this restriction will cause handlers to throw.
|
||||
* Default: {}()/\@:
|
||||
*
|
||||
* NOTE: The default set is required for PSR-6 compliance.
|
||||
*/
|
||||
public string $reservedCharacters = '{}()/\@:';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* File settings
|
||||
* --------------------------------------------------------------------------
|
||||
* Your file storage preferences can be specified below, if you are using
|
||||
* the File driver.
|
||||
*
|
||||
* @var array<string, int|string|null>
|
||||
*/
|
||||
public array $file = [
|
||||
'storePath' => WRITEPATH . 'cache/',
|
||||
'mode' => 0640,
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Memcached settings
|
||||
* -------------------------------------------------------------------------
|
||||
* Your Memcached servers can be specified below, if you are using
|
||||
* the Memcached drivers.
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/libraries/caching.html#memcached
|
||||
*
|
||||
* @var array<string, bool|int|string>
|
||||
*/
|
||||
public array $memcached = [
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 11211,
|
||||
'weight' => 1,
|
||||
'raw' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------------
|
||||
* Redis settings
|
||||
* -------------------------------------------------------------------------
|
||||
* Your Redis server can be specified below, if you are using
|
||||
* the Redis or Predis drivers.
|
||||
*
|
||||
* @var array<string, int|string|null>
|
||||
*/
|
||||
public array $redis = [
|
||||
'host' => '127.0.0.1',
|
||||
'password' => null,
|
||||
'port' => 6379,
|
||||
'timeout' => 0,
|
||||
'database' => 0,
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Available Cache Handlers
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is an array of cache engine alias' and class names. Only engines
|
||||
* that are listed here are allowed to be used.
|
||||
*
|
||||
* @var array<string, class-string<CacheInterface>>
|
||||
*/
|
||||
public array $validHandlers = [
|
||||
'dummy' => DummyHandler::class,
|
||||
'file' => FileHandler::class,
|
||||
'memcached' => MemcachedHandler::class,
|
||||
'predis' => PredisHandler::class,
|
||||
'redis' => RedisHandler::class,
|
||||
'wincache' => WincacheHandler::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Web Page Caching: Cache Include Query String
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Whether to take the URL query string into consideration when generating
|
||||
* output cache files. Valid options are:
|
||||
*
|
||||
* false = Disabled
|
||||
* true = Enabled, take all query parameters into account.
|
||||
* Please be aware that this may result in numerous cache
|
||||
* files generated for the same page over and over again.
|
||||
* ['q'] = Enabled, but only take into account the specified list
|
||||
* of query parameters.
|
||||
*
|
||||
* @var bool|list<string>
|
||||
*/
|
||||
public $cacheQueryString = false;
|
||||
}
|
||||
187
app/Config/Constants.php
Normal file
187
app/Config/Constants.php
Normal file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
| --------------------------------------------------------------------
|
||||
| App Namespace
|
||||
| --------------------------------------------------------------------
|
||||
|
|
||||
| This defines the default Namespace that is used throughout
|
||||
| CodeIgniter to refer to the Application directory. Change
|
||||
| this constant to change the namespace that all application
|
||||
| classes should use.
|
||||
|
|
||||
| NOTE: changing this will require manually modifying the
|
||||
| existing namespaces of App\* namespaced-classes.
|
||||
*/
|
||||
defined('APP_NAMESPACE') || define('APP_NAMESPACE', 'App');
|
||||
|
||||
/*
|
||||
| --------------------------------------------------------------------------
|
||||
| Composer Path
|
||||
| --------------------------------------------------------------------------
|
||||
|
|
||||
| The path that Composer's autoload file is expected to live. By default,
|
||||
| the vendor folder is in the Root directory, but you can customize that here.
|
||||
*/
|
||||
defined('COMPOSER_PATH') || define('COMPOSER_PATH', ROOTPATH . 'vendor/autoload.php');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Timing Constants
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Provide simple ways to work with the myriad of PHP functions that
|
||||
| require information to be in seconds.
|
||||
*/
|
||||
defined('SECOND') || define('SECOND', 1);
|
||||
defined('MINUTE') || define('MINUTE', 60);
|
||||
defined('HOUR') || define('HOUR', 3600);
|
||||
defined('DAY') || define('DAY', 86400);
|
||||
defined('WEEK') || define('WEEK', 604800);
|
||||
defined('MONTH') || define('MONTH', 2_592_000);
|
||||
defined('YEAR') || define('YEAR', 31_536_000);
|
||||
defined('DECADE') || define('DECADE', 315_360_000);
|
||||
defined('DEFAULT_DATE') || define('DEFAULT_DATE', mktime(0, 0, 0, 1, 1, 2010));
|
||||
defined('DEFAULT_DATETIME') || define('DEFAULT_DATETIME', mktime(0, 0, 0, 1, 1, 2010));
|
||||
defined('NOW') || define('NOW', time());
|
||||
|
||||
|
||||
/*
|
||||
| --------------------------------------------------------------------------
|
||||
| Exit Status Codes
|
||||
| --------------------------------------------------------------------------
|
||||
|
|
||||
| Used to indicate the conditions under which the script is exit()ing.
|
||||
| While there is no universal standard for error codes, there are some
|
||||
| broad conventions. Three such conventions are mentioned below, for
|
||||
| those who wish to make use of them. The CodeIgniter defaults were
|
||||
| chosen for the least overlap with these conventions, while still
|
||||
| leaving room for others to be defined in future versions and user
|
||||
| applications.
|
||||
|
|
||||
| The three main conventions used for determining exit status codes
|
||||
| are as follows:
|
||||
|
|
||||
| Standard C/C++ Library (stdlibc):
|
||||
| http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
|
||||
| (This link also contains other GNU-specific conventions)
|
||||
| BSD sysexits.h:
|
||||
| http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
|
||||
| Bash scripting:
|
||||
| http://tldp.org/LDP/abs/html/exitcodes.html
|
||||
|
|
||||
*/
|
||||
defined('EXIT_SUCCESS') || define('EXIT_SUCCESS', 0); // no errors
|
||||
defined('EXIT_ERROR') || define('EXIT_ERROR', 1); // generic error
|
||||
defined('EXIT_CONFIG') || define('EXIT_CONFIG', 3); // configuration error
|
||||
defined('EXIT_UNKNOWN_FILE') || define('EXIT_UNKNOWN_FILE', 4); // file not found
|
||||
defined('EXIT_UNKNOWN_CLASS') || define('EXIT_UNKNOWN_CLASS', 5); // unknown class
|
||||
defined('EXIT_UNKNOWN_METHOD') || define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
|
||||
defined('EXIT_USER_INPUT') || define('EXIT_USER_INPUT', 7); // invalid user input
|
||||
defined('EXIT_DATABASE') || define('EXIT_DATABASE', 8); // database error
|
||||
defined('EXIT__AUTO_MIN') || define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
|
||||
defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code
|
||||
|
||||
/**
|
||||
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_LOW instead.
|
||||
*/
|
||||
define('EVENT_PRIORITY_LOW', 200);
|
||||
|
||||
/**
|
||||
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_NORMAL instead.
|
||||
*/
|
||||
define('EVENT_PRIORITY_NORMAL', 100);
|
||||
|
||||
/**
|
||||
* @deprecated Use \CodeIgniter\Events\Events::PRIORITY_HIGH instead.
|
||||
*/
|
||||
define('EVENT_PRIORITY_HIGH', 10);
|
||||
|
||||
/**
|
||||
* Global Constants.
|
||||
*/
|
||||
const NEW_ENTRY = -1;
|
||||
const ACTIVE = 0;
|
||||
const DELETED = 1;
|
||||
|
||||
/**
|
||||
* Attribute Related Constants.
|
||||
*/
|
||||
const GROUP = 'GROUP';
|
||||
const DROPDOWN = 'DROPDOWN';
|
||||
const DECIMAL = 'DECIMAL';
|
||||
const DATE = 'DATE';
|
||||
const TEXT = 'TEXT';
|
||||
const CHECKBOX = 'CHECKBOX';
|
||||
const NO_DEFINITION_ID = 0;
|
||||
const CATEGORY_DEFINITION_ID = -1;
|
||||
const DEFINITION_TYPES = [GROUP, DROPDOWN, DECIMAL, TEXT, DATE, CHECKBOX];
|
||||
|
||||
/**
|
||||
* Item Related Constants.
|
||||
*/
|
||||
const HAS_STOCK = 0;
|
||||
const HAS_NO_STOCK = 1;
|
||||
|
||||
const ITEM = 0;
|
||||
const ITEM_KIT = 1;
|
||||
const ITEM_AMOUNT_ENTRY = 2;
|
||||
const ITEM_TEMP = 3;
|
||||
const NEW_ITEM = -1;
|
||||
|
||||
const PRINT_ALL = 0;
|
||||
const PRINT_PRICED = 1;
|
||||
const PRINT_KIT = 2;
|
||||
|
||||
const PRINT_YES = 0;
|
||||
const PRINT_NO = 1;
|
||||
|
||||
const PRICE_ALL = 0;
|
||||
const PRICE_KIT = 1;
|
||||
const PRICE_KIT_ITEMS = 2;
|
||||
|
||||
const PRICE_OPTION_ALL = 0;
|
||||
const PRICE_OPTION_KIT = 1;
|
||||
const PRICE_OPTION_KIT_STOCK = 2;
|
||||
|
||||
const NAME_SEPARATOR = ' | ';
|
||||
|
||||
/**
|
||||
* Sale Related Constants.
|
||||
*/
|
||||
const COMPLETED = 0;
|
||||
const SUSPENDED = 1;
|
||||
const CANCELED = 2;
|
||||
|
||||
const SALE_TYPE_POS = 0;
|
||||
const SALE_TYPE_INVOICE = 1;
|
||||
const SALE_TYPE_WORK_ORDER = 2;
|
||||
const SALE_TYPE_QUOTE = 3;
|
||||
const SALE_TYPE_RETURN = 4;
|
||||
|
||||
const PERCENT = 0;
|
||||
const FIXED = 1;
|
||||
|
||||
const PRICE_MODE_STANDARD = 0;
|
||||
const PRICE_MODE_KIT = 1;
|
||||
|
||||
const PAYMENT_TYPE_UNASSIGNED = '--';
|
||||
|
||||
const CASH_ADJUSTMENT_TRUE = 1;
|
||||
const CASH_ADJUSTMENT_FALSE = 0;
|
||||
const CASH_MODE_TRUE = 1;
|
||||
const CASH_MODE_FALSE = 0;
|
||||
|
||||
/**
|
||||
* Supplier Related Constants
|
||||
*/
|
||||
const GOODS_SUPPLIER = 0;
|
||||
const COST_SUPPLIER = 1;
|
||||
|
||||
/**
|
||||
* Locale Related Constants
|
||||
*/
|
||||
const MAX_PRECISION = 1e14;
|
||||
const DEFAULT_PRECISION = 2;
|
||||
const DEFAULT_LANGUAGE = 'english';
|
||||
const DEFAULT_LANGUAGE_CODE = 'en';
|
||||
176
app/Config/ContentSecurityPolicy.php
Normal file
176
app/Config/ContentSecurityPolicy.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* Stores the default settings for the ContentSecurityPolicy, if you
|
||||
* choose to use it. The values here will be read in and set as defaults
|
||||
* for the site. If needed, they can be overridden on a page-by-page basis.
|
||||
*
|
||||
* Suggested reference for explanations:
|
||||
*
|
||||
* @see https://www.html5rocks.com/en/tutorials/security/content-security-policy/
|
||||
*/
|
||||
class ContentSecurityPolicy extends BaseConfig
|
||||
{
|
||||
// -------------------------------------------------------------------------
|
||||
// Broadbrush CSP management
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Default CSP report context
|
||||
*/
|
||||
public bool $reportOnly = false;
|
||||
|
||||
/**
|
||||
* Specifies a URL where a browser will send reports
|
||||
* when a content security policy is violated.
|
||||
*/
|
||||
public ?string $reportURI = null;
|
||||
|
||||
/**
|
||||
* Instructs user agents to rewrite URL schemes, changing
|
||||
* HTTP to HTTPS. This directive is for websites with
|
||||
* large numbers of old URLs that need to be rewritten.
|
||||
*/
|
||||
public bool $upgradeInsecureRequests = false;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Sources allowed
|
||||
// NOTE: once you set a policy to 'none', it cannot be further restricted
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Will default to self if not overridden
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $defaultSrc;
|
||||
|
||||
/**
|
||||
* Lists allowed scripts' URLs.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $scriptSrc = 'self';
|
||||
|
||||
/**
|
||||
* Lists allowed stylesheets' URLs.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $styleSrc = 'self';
|
||||
|
||||
/**
|
||||
* Defines the origins from which images can be loaded.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $imageSrc = 'self';
|
||||
|
||||
/**
|
||||
* Restricts the URLs that can appear in a page's `<base>` element.
|
||||
*
|
||||
* Will default to self if not overridden
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $baseURI;
|
||||
|
||||
/**
|
||||
* Lists the URLs for workers and embedded frame contents
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $childSrc = 'self';
|
||||
|
||||
/**
|
||||
* Limits the origins that you can connect to (via XHR,
|
||||
* WebSockets, and EventSource).
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $connectSrc = 'self';
|
||||
|
||||
/**
|
||||
* Specifies the origins that can serve web fonts.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $fontSrc;
|
||||
|
||||
/**
|
||||
* Lists valid endpoints for submission from `<form>` tags.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $formAction = 'self';
|
||||
|
||||
/**
|
||||
* Specifies the sources that can embed the current page.
|
||||
* This directive applies to `<frame>`, `<iframe>`, `<embed>`,
|
||||
* and `<applet>` tags. This directive can't be used in
|
||||
* `<meta>` tags and applies only to non-HTML resources.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $frameAncestors;
|
||||
|
||||
/**
|
||||
* The frame-src directive restricts the URLs which may
|
||||
* be loaded into nested browsing contexts.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $frameSrc;
|
||||
|
||||
/**
|
||||
* Restricts the origins allowed to deliver video and audio.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $mediaSrc;
|
||||
|
||||
/**
|
||||
* Allows control over Flash and other plugins.
|
||||
*
|
||||
* @var list<string>|string
|
||||
*/
|
||||
public $objectSrc = 'self';
|
||||
|
||||
/**
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $manifestSrc;
|
||||
|
||||
/**
|
||||
* Limits the kinds of plugins a page may invoke.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $pluginTypes;
|
||||
|
||||
/**
|
||||
* List of actions allowed.
|
||||
*
|
||||
* @var list<string>|string|null
|
||||
*/
|
||||
public $sandbox;
|
||||
|
||||
/**
|
||||
* Nonce tag for style
|
||||
*/
|
||||
public string $styleNonceTag = '{csp-style-nonce}';
|
||||
|
||||
/**
|
||||
* Nonce tag for script
|
||||
*/
|
||||
public string $scriptNonceTag = '{csp-script-nonce}';
|
||||
|
||||
/**
|
||||
* Replace nonce tag automatically
|
||||
*/
|
||||
public bool $autoNonce = true;
|
||||
}
|
||||
107
app/Config/Cookie.php
Normal file
107
app/Config/Cookie.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use DateTimeInterface;
|
||||
|
||||
class Cookie extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Prefix
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Set a cookie name prefix if you need to avoid collisions.
|
||||
*/
|
||||
public string $prefix = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Expires Timestamp
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Default expires timestamp for cookies. Setting this to `0` will mean the
|
||||
* cookie will not have the `Expires` attribute and will behave as a session
|
||||
* cookie.
|
||||
*
|
||||
* @var DateTimeInterface|int|string
|
||||
*/
|
||||
public $expires = 0;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Path
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Typically will be a forward slash.
|
||||
*/
|
||||
public string $path = '/';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Domain
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Set to `.your-domain.com` for site-wide cookies.
|
||||
*/
|
||||
public string $domain = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Secure
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Cookie will only be set if a secure HTTPS connection exists.
|
||||
*/
|
||||
public bool $secure = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie HTTPOnly
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Cookie will only be accessible via HTTP(S) (no JavaScript).
|
||||
*/
|
||||
public bool $httponly = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie SameSite
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Configure cookie SameSite setting. Allowed values are:
|
||||
* - None
|
||||
* - Lax
|
||||
* - Strict
|
||||
* - ''
|
||||
*
|
||||
* Alternatively, you can use the constant names:
|
||||
* - `Cookie::SAMESITE_NONE`
|
||||
* - `Cookie::SAMESITE_LAX`
|
||||
* - `Cookie::SAMESITE_STRICT`
|
||||
*
|
||||
* Defaults to `Lax` for compatibility with modern browsers. Setting `''`
|
||||
* (empty string) means default SameSite attribute set by browsers (`Lax`)
|
||||
* will be set on cookies. If set to `None`, `$secure` must also be set.
|
||||
*
|
||||
* @phpstan-var 'None'|'Lax'|'Strict'|''
|
||||
*/
|
||||
public string $samesite = 'Lax';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Cookie Raw
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This flag allows setting a "raw" cookie, i.e., its name and value are
|
||||
* not URL encoded using `rawurlencode()`.
|
||||
*
|
||||
* If this is set to `true`, cookie names should be compliant of RFC 2616's
|
||||
* list of allowed characters.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#attributes
|
||||
* @see https://tools.ietf.org/html/rfc2616#section-2.2
|
||||
*/
|
||||
public bool $raw = false;
|
||||
}
|
||||
105
app/Config/Cors.php
Normal file
105
app/Config/Cors.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* Cross-Origin Resource Sharing (CORS) Configuration
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
||||
*/
|
||||
class Cors extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* The default CORS configuration.
|
||||
*
|
||||
* @var array{
|
||||
* allowedOrigins: list<string>,
|
||||
* allowedOriginsPatterns: list<string>,
|
||||
* supportsCredentials: bool,
|
||||
* allowedHeaders: list<string>,
|
||||
* exposedHeaders: list<string>,
|
||||
* allowedMethods: list<string>,
|
||||
* maxAge: int,
|
||||
* }
|
||||
*/
|
||||
public array $default = [
|
||||
/**
|
||||
* Origins for the `Access-Control-Allow-Origin` header.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
|
||||
*
|
||||
* E.g.:
|
||||
* - ['http://localhost:8080']
|
||||
* - ['https://www.example.com']
|
||||
*/
|
||||
'allowedOrigins' => [],
|
||||
|
||||
/**
|
||||
* Origin regex patterns for the `Access-Control-Allow-Origin` header.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
|
||||
*
|
||||
* NOTE: A pattern specified here is part of a regular expression. It will
|
||||
* be actually `#\A<pattern>\z#`.
|
||||
*
|
||||
* E.g.:
|
||||
* - ['https://\w+\.example\.com']
|
||||
*/
|
||||
'allowedOriginsPatterns' => [],
|
||||
|
||||
/**
|
||||
* Weather to send the `Access-Control-Allow-Credentials` header.
|
||||
*
|
||||
* The Access-Control-Allow-Credentials response header tells browsers whether
|
||||
* the server allows cross-origin HTTP requests to include credentials.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
|
||||
*/
|
||||
'supportsCredentials' => false,
|
||||
|
||||
/**
|
||||
* Set headers to allow.
|
||||
*
|
||||
* The Access-Control-Allow-Headers response header is used in response to
|
||||
* a preflight request which includes the Access-Control-Request-Headers to
|
||||
* indicate which HTTP headers can be used during the actual request.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
|
||||
*/
|
||||
'allowedHeaders' => [],
|
||||
|
||||
/**
|
||||
* Set headers to expose.
|
||||
*
|
||||
* The Access-Control-Expose-Headers response header allows a server to
|
||||
* indicate which response headers should be made available to scripts running
|
||||
* in the browser, in response to a cross-origin request.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
|
||||
*/
|
||||
'exposedHeaders' => [],
|
||||
|
||||
/**
|
||||
* Set methods to allow.
|
||||
*
|
||||
* The Access-Control-Allow-Methods response header specifies one or more
|
||||
* methods allowed when accessing a resource in response to a preflight
|
||||
* request.
|
||||
*
|
||||
* E.g.:
|
||||
* - ['GET', 'POST', 'PUT', 'DELETE']
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
|
||||
*/
|
||||
'allowedMethods' => [],
|
||||
|
||||
/**
|
||||
* Set how many seconds the results of a preflight request can be cached.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
|
||||
*/
|
||||
'maxAge' => 7200,
|
||||
];
|
||||
}
|
||||
146
app/Config/Database.php
Normal file
146
app/Config/Database.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Database\Config;
|
||||
|
||||
/**
|
||||
* Database Configuration
|
||||
*/
|
||||
class Database extends Config
|
||||
{
|
||||
/**
|
||||
* The directory that holds the Migrations and Seeds directories.
|
||||
*/
|
||||
public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Lets you choose which connection group to use if no other is specified.
|
||||
*/
|
||||
public string $defaultGroup = 'default';
|
||||
|
||||
/**
|
||||
* The default database connection.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public array $default = [
|
||||
'DSN' => '',
|
||||
'hostname' => 'localhost',
|
||||
'username' => 'admin',
|
||||
'password' => 'pointofsale',
|
||||
'database' => 'ospos',
|
||||
'DBDriver' => 'MySQLi',
|
||||
'DBPrefix' => 'ospos_',
|
||||
'pConnect' => false,
|
||||
'DBDebug' => (ENVIRONMENT !== 'production'),
|
||||
'charset' => 'utf8mb4',
|
||||
'DBCollat' => 'utf8mb4_general_ci',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'numberNative' => false,
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'datetime' => 'Y-m-d H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* This database connection is used when
|
||||
* running PHPUnit database tests.
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
public array $tests = [
|
||||
'DSN' => '',
|
||||
'hostname' => 'localhost',
|
||||
'username' => 'admin',
|
||||
'password' => 'pointofsale',
|
||||
'database' => 'ospos',
|
||||
'DBDriver' => 'MySQLi',
|
||||
'DBPrefix' => 'ospos_',
|
||||
'pConnect' => false,
|
||||
'DBDebug' => (ENVIRONMENT !== 'production'),
|
||||
'charset' => 'utf8mb4',
|
||||
'DBCollat' => 'utf8mb4_general_ci',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'foreignKeys' => true,
|
||||
'busyTimeout' => 1000,
|
||||
'numberNative' => false,
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'datetime' => 'Y-m-d H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* This database connection is used when
|
||||
* developing against non-production data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $development = [
|
||||
'DSN' => '',
|
||||
'hostname' => 'localhost',
|
||||
'username' => 'admin',
|
||||
'password' => 'pointofsale',
|
||||
'database' => 'ospos',
|
||||
'DBDriver' => 'MySQLi',
|
||||
'DBPrefix' => 'ospos_',
|
||||
'pConnect' => false,
|
||||
'DBDebug' => (ENVIRONMENT !== 'production'),
|
||||
'charset' => 'utf8mb4',
|
||||
'DBCollat' => 'utf8mb4_general_ci',
|
||||
'swapPre' => '',
|
||||
'encrypt' => false,
|
||||
'compress' => false,
|
||||
'strictOn' => false,
|
||||
'failover' => [],
|
||||
'port' => 3306,
|
||||
'foreignKeys' => true,
|
||||
'busyTimeout' => 1000,
|
||||
'numberNative' => false,
|
||||
'dateFormat' => [
|
||||
'date' => 'Y-m-d',
|
||||
'datetime' => 'Y-m-d H:i:s',
|
||||
'time' => 'H:i:s',
|
||||
],
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Ensure that we always set the database group to 'tests' if
|
||||
// we are currently running an automated test suite, so that
|
||||
// we don't overwrite live data on accident.
|
||||
switch(ENVIRONMENT)
|
||||
{
|
||||
case 'testing':
|
||||
$this->defaultGroup = 'tests';
|
||||
break;
|
||||
case 'development';
|
||||
$this->defaultGroup = 'development';
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ([&$this->development, &$this->tests, &$this->default] as &$config)
|
||||
{
|
||||
$config['hostname'] = !getenv('MYSQL_HOST_NAME') ? $config['hostname'] : getenv('MYSQL_HOST_NAME');
|
||||
$config['username'] = !getenv('MYSQL_USERNAME') ? $config['username'] : getenv('MYSQL_USERNAME');
|
||||
$config['password'] = !getenv('MYSQL_PASSWORD') ? $config['password'] : getenv('MYSQL_PASSWORD');
|
||||
$config['database'] = !getenv('MYSQL_DB_NAME') ? $config['database'] : getenv('MYSQL_DB_NAME');
|
||||
}
|
||||
}
|
||||
}
|
||||
46
app/Config/DocTypes.php
Normal file
46
app/Config/DocTypes.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* @immutable
|
||||
*/
|
||||
class DocTypes
|
||||
{
|
||||
/**
|
||||
* List of valid document types.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $list = [
|
||||
'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
|
||||
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
|
||||
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
|
||||
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
|
||||
'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
|
||||
'html5' => '<!DOCTYPE html>',
|
||||
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
|
||||
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
|
||||
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
|
||||
'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
|
||||
'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
|
||||
'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
|
||||
'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
|
||||
'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
|
||||
'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
|
||||
'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
|
||||
'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
|
||||
'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
|
||||
'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">',
|
||||
];
|
||||
|
||||
/**
|
||||
* Whether to remove the solidus (`/`) character for void HTML elements (e.g. `<input>`)
|
||||
* for HTML5 compatibility.
|
||||
*
|
||||
* Set to:
|
||||
* `true` - to be HTML5 compatible
|
||||
* `false` - to be XHTML compatible
|
||||
*/
|
||||
public bool $html5 = true;
|
||||
}
|
||||
121
app/Config/Email.php
Normal file
121
app/Config/Email.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Email extends BaseConfig
|
||||
{
|
||||
public string $fromEmail = 'noreply@opensourcepos.org';
|
||||
public string $fromName = 'Opensource Point of Sale';
|
||||
public string $recipients = 'blackhole@none.com';
|
||||
|
||||
/**
|
||||
* The "user agent"
|
||||
*/
|
||||
public string $userAgent = 'CodeIgniter';
|
||||
|
||||
/**
|
||||
* The mail sending protocol: mail, sendmail, smtp
|
||||
*/
|
||||
public string $protocol = 'mail';
|
||||
|
||||
/**
|
||||
* The server path to Sendmail.
|
||||
*/
|
||||
public string $mailPath = '/usr/sbin/sendmail';
|
||||
|
||||
/**
|
||||
* SMTP Server Hostname
|
||||
*/
|
||||
public string $SMTPHost = 'mail.mxserver.com';
|
||||
|
||||
/**
|
||||
* SMTP Username
|
||||
*/
|
||||
public string $SMTPUser = 'user';
|
||||
|
||||
/**
|
||||
* SMTP Password
|
||||
*/
|
||||
public string $SMTPPass = 'pass';
|
||||
|
||||
/**
|
||||
* SMTP Port
|
||||
*/
|
||||
public int $SMTPPort = 25;
|
||||
|
||||
/**
|
||||
* SMTP Timeout (in seconds)
|
||||
*/
|
||||
public int $SMTPTimeout = 5;
|
||||
|
||||
/**
|
||||
* Enable persistent SMTP connections
|
||||
*/
|
||||
public bool $SMTPKeepAlive = false;
|
||||
|
||||
/**
|
||||
* SMTP Encryption.
|
||||
*
|
||||
* @var string '', 'tls' or 'ssl'. 'tls' will issue a STARTTLS command
|
||||
* to the server. 'ssl' means implicit SSL. Connection on port
|
||||
* 465 should set this to ''.
|
||||
*/
|
||||
public string $SMTPCrypto = 'tls';
|
||||
|
||||
/**
|
||||
* Enable word-wrap
|
||||
*/
|
||||
public bool $wordWrap = true;
|
||||
|
||||
/**
|
||||
* Character count to wrap at
|
||||
*/
|
||||
public int $wrapChars = 76;
|
||||
|
||||
/**
|
||||
* Type of mail, either 'text' or 'html'
|
||||
*/
|
||||
public string $mailType = 'html';
|
||||
|
||||
/**
|
||||
* Character set (utf-8, iso-8859-1, etc.)
|
||||
*/
|
||||
public string $charset = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Whether to validate the email address
|
||||
*/
|
||||
public bool $validate = false;
|
||||
|
||||
/**
|
||||
* Email Priority. 1 = highest. 5 = lowest. 3 = normal
|
||||
*/
|
||||
public int $priority = 3;
|
||||
|
||||
/**
|
||||
* Newline character. (Use “\r\n” to comply with RFC 822)
|
||||
*/
|
||||
public string $CRLF = "\r\n";
|
||||
|
||||
/**
|
||||
* Newline character. (Use “\r\n” to comply with RFC 822)
|
||||
*/
|
||||
public string $newline = "\r\n";
|
||||
|
||||
/**
|
||||
* Enable BCC Batch Mode.
|
||||
*/
|
||||
public bool $BCCBatchMode = false;
|
||||
|
||||
/**
|
||||
* Number of emails in each BCC batch
|
||||
*/
|
||||
public int $BCCBatchSize = 200;
|
||||
|
||||
/**
|
||||
* Enable notify message from server
|
||||
*/
|
||||
public bool $DSN = false;
|
||||
}
|
||||
92
app/Config/Encryption.php
Normal file
92
app/Config/Encryption.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* Encryption configuration.
|
||||
*
|
||||
* These are the settings used for encryption, if you don't pass a parameter
|
||||
* array to the encrypter for creation/initialization.
|
||||
*/
|
||||
class Encryption extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Encryption Key Starter
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If you use the Encryption class you must set an encryption key (seed).
|
||||
* You need to ensure it is long enough for the cipher and mode you plan to use.
|
||||
* See the user guide for more info.
|
||||
*/
|
||||
public string $key = '';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Encryption Driver to Use
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* One of the supported encryption drivers.
|
||||
*
|
||||
* Available drivers:
|
||||
* - OpenSSL
|
||||
* - Sodium
|
||||
*/
|
||||
public string $driver = 'OpenSSL';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* SodiumHandler's Padding Length in Bytes
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is the number of bytes that will be padded to the plaintext message
|
||||
* before it is encrypted. This value should be greater than zero.
|
||||
*
|
||||
* See the user guide for more information on padding.
|
||||
*/
|
||||
public int $blockSize = 16;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Encryption digest
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* HMAC digest to use, e.g. 'SHA512' or 'SHA256'. Default value is 'SHA512'.
|
||||
*/
|
||||
public string $digest = 'SHA512';
|
||||
|
||||
/**
|
||||
* Whether the cipher-text should be raw. If set to false, then it will be base64 encoded.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to false for CI3 Encryption compatibility.
|
||||
*/
|
||||
public bool $rawData = false;
|
||||
|
||||
/**
|
||||
* Encryption key info.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to 'encryption' for CI3 Encryption compatibility.
|
||||
*/
|
||||
public string $encryptKeyInfo = '';
|
||||
|
||||
/**
|
||||
* Authentication key info.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to 'authentication' for CI3 Encryption compatibility.
|
||||
*/
|
||||
public string $authKeyInfo = '';
|
||||
|
||||
/**
|
||||
* Cipher to use.
|
||||
* This setting is only used by OpenSSLHandler.
|
||||
*
|
||||
* Set to 'AES-128-CBC' to decrypt encrypted data that encrypted
|
||||
* by CI3 Encryption default configuration.
|
||||
*/
|
||||
public string $cipher = 'AES-256-CTR';
|
||||
}
|
||||
67
app/Config/Events.php
Normal file
67
app/Config/Events.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use App\Events\Db_log;
|
||||
use App\Events\Load_config;
|
||||
use App\Events\Method;
|
||||
use CodeIgniter\Events\Events;
|
||||
use CodeIgniter\Exceptions\FrameworkException;
|
||||
use CodeIgniter\HotReloader\HotReloader;
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Application Events
|
||||
* --------------------------------------------------------------------
|
||||
* Events allow you to tap into the execution of the program without
|
||||
* modifying or extending core files. This file provides a central
|
||||
* location to define your events, though they can always be added
|
||||
* at run-time, also, if needed.
|
||||
*
|
||||
* You create code that can execute by subscribing to events with
|
||||
* the 'on()' method. This accepts any form of callable, including
|
||||
* Closures, that will be executed when the event is triggered.
|
||||
*
|
||||
* Example:
|
||||
* Events::on('create', [$myInstance, 'myMethod']);
|
||||
*/
|
||||
|
||||
Events::on('pre_system', static function () {
|
||||
if (ENVIRONMENT !== 'testing') {
|
||||
if (ini_get('zlib.output_compression')) {
|
||||
throw FrameworkException::forEnabledZlibOutputCompression();
|
||||
}
|
||||
|
||||
while (ob_get_level() > 0) {
|
||||
ob_end_flush();
|
||||
}
|
||||
|
||||
ob_start(static fn ($buffer) => $buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* Debug Toolbar Listeners.
|
||||
* --------------------------------------------------------------------
|
||||
* If you delete, they will no longer be collected.
|
||||
*/
|
||||
if (CI_DEBUG && ! is_cli()) {
|
||||
Events::on('DBQuery', 'CodeIgniter\Debug\Toolbar\Collectors\Database::collect');
|
||||
Services::toolbar()->respond();
|
||||
// Hot Reload route - for framework use on the hot reloader.
|
||||
if (ENVIRONMENT === 'development') {
|
||||
Services::routes()->get('__hot-reload', static function () {
|
||||
(new HotReloader())->run();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$config = new Load_config();
|
||||
Events::on('post_controller_constructor', [$config, 'load_config']);
|
||||
|
||||
$db_log = new Db_log();
|
||||
Events::on('DBQuery', [$db_log, 'db_log_queries']);
|
||||
|
||||
$method = new Method();
|
||||
Events::on('pre_controller', [$method, 'validate_method']);
|
||||
108
app/Config/Exceptions.php
Normal file
108
app/Config/Exceptions.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Debug\ExceptionHandler;
|
||||
use CodeIgniter\Debug\ExceptionHandlerInterface;
|
||||
use Psr\Log\LogLevel;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Setup how the exception handler works.
|
||||
*/
|
||||
class Exceptions extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* LOG EXCEPTIONS?
|
||||
* --------------------------------------------------------------------------
|
||||
* If true, then exceptions will be logged
|
||||
* through Services::Log.
|
||||
*
|
||||
* Default: true
|
||||
*/
|
||||
public bool $log = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* DO NOT LOG STATUS CODES
|
||||
* --------------------------------------------------------------------------
|
||||
* Any status codes here will NOT be logged if logging is turned on.
|
||||
* By default, only 404 (Page Not Found) exceptions are ignored.
|
||||
*
|
||||
* @var list<int>
|
||||
*/
|
||||
public array $ignoreCodes = [404];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Error Views Path
|
||||
* --------------------------------------------------------------------------
|
||||
* This is the path to the directory that contains the 'cli' and 'html'
|
||||
* directories that hold the views used to generate errors.
|
||||
*
|
||||
* Default: APPPATH.'Views/errors'
|
||||
*/
|
||||
public string $errorViewPath = APPPATH . 'Views/errors';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* HIDE FROM DEBUG TRACE
|
||||
* --------------------------------------------------------------------------
|
||||
* Any data that you would like to hide from the debug trace.
|
||||
* In order to specify 2 levels, use "/" to separate.
|
||||
* ex. ['server', 'setup/password', 'secret_token']
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $sensitiveDataInTrace = [];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* LOG DEPRECATIONS INSTEAD OF THROWING?
|
||||
* --------------------------------------------------------------------------
|
||||
* By default, CodeIgniter converts deprecations into exceptions. Also,
|
||||
* starting in PHP 8.1 will cause a lot of deprecated usage warnings.
|
||||
* Use this option to temporarily cease the warnings and instead log those.
|
||||
* This option also works for user deprecations.
|
||||
*/
|
||||
public bool $logDeprecations = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* LOG LEVEL THRESHOLD FOR DEPRECATIONS
|
||||
* --------------------------------------------------------------------------
|
||||
* If `$logDeprecations` is set to `true`, this sets the log level
|
||||
* to which the deprecation will be logged. This should be one of the log
|
||||
* levels recognized by PSR-3.
|
||||
*
|
||||
* The related `Config\Logger::$threshold` should be adjusted, if needed,
|
||||
* to capture logging the deprecations.
|
||||
*/
|
||||
public string $deprecationLogLevel = LogLevel::WARNING;
|
||||
|
||||
/**
|
||||
* DEFINE THE HANDLERS USED
|
||||
* --------------------------------------------------------------------------
|
||||
* Given the HTTP status code, returns exception handler that
|
||||
* should be used to deal with this error. By default, it will run CodeIgniter's
|
||||
* default handler and display the error information in the expected format
|
||||
* for CLI, HTTP, or AJAX requests, as determined by is_cli() and the expected
|
||||
* response format.
|
||||
*
|
||||
* Custom handlers can be returned if you want to handle one or more specific
|
||||
* error codes yourself like:
|
||||
*
|
||||
* if (in_array($statusCode, [400, 404, 500])) {
|
||||
* return new \App\Libraries\MyExceptionHandler();
|
||||
* }
|
||||
* if ($exception instanceOf PageNotFoundException) {
|
||||
* return new \App\Libraries\MyExceptionHandler();
|
||||
* }
|
||||
*/
|
||||
public function handler(int $statusCode, Throwable $exception): ExceptionHandlerInterface
|
||||
{
|
||||
return new ExceptionHandler($this);
|
||||
}
|
||||
}
|
||||
29
app/Config/Feature.php
Normal file
29
app/Config/Feature.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* Enable/disable backward compatibility breaking features.
|
||||
*/
|
||||
class Feature extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Use improved new auto routing instead of the default legacy version.
|
||||
*/
|
||||
public bool $autoRoutesImproved = true;
|
||||
|
||||
/**
|
||||
* Use filter execution order in 4.4 or before.
|
||||
*/
|
||||
public bool $oldFilterOrder = false;
|
||||
|
||||
/**
|
||||
* The behavior of `limit(0)` in Query Builder.
|
||||
*
|
||||
* If true, `limit(0)` returns all records. (the behavior of 4.4.x or before in version 4.x.)
|
||||
* If false, `limit(0)` returns no records. (the behavior of 3.1.9 or later in version 3.x.)
|
||||
*/
|
||||
public bool $limitZeroAsAll = true;
|
||||
}
|
||||
108
app/Config/Filters.php
Normal file
108
app/Config/Filters.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\Filters as BaseFilters;
|
||||
use CodeIgniter\Filters\Cors;
|
||||
use CodeIgniter\Filters\CSRF;
|
||||
use CodeIgniter\Filters\DebugToolbar;
|
||||
use CodeIgniter\Filters\ForceHTTPS;
|
||||
use CodeIgniter\Filters\Honeypot;
|
||||
use CodeIgniter\Filters\InvalidChars;
|
||||
use CodeIgniter\Filters\PageCache;
|
||||
use CodeIgniter\Filters\PerformanceMetrics;
|
||||
use CodeIgniter\Filters\SecureHeaders;
|
||||
|
||||
class Filters extends BaseFilters
|
||||
{
|
||||
/**
|
||||
* Configures aliases for Filter classes to
|
||||
* make reading things nicer and simpler.
|
||||
*
|
||||
* @var array<string, class-string|list<class-string>>
|
||||
*
|
||||
* [filter_name => classname]
|
||||
* or [filter_name => [classname1, classname2, ...]]
|
||||
*/
|
||||
public array $aliases = [
|
||||
'csrf' => CSRF::class,
|
||||
'toolbar' => DebugToolbar::class,
|
||||
'honeypot' => Honeypot::class,
|
||||
'invalidchars' => InvalidChars::class,
|
||||
'secureheaders' => SecureHeaders::class,
|
||||
'cors' => Cors::class,
|
||||
'forcehttps' => ForceHTTPS::class,
|
||||
'pagecache' => PageCache::class,
|
||||
'performance' => PerformanceMetrics::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* List of special required filters.
|
||||
*
|
||||
* The filters listed here are special. They are applied before and after
|
||||
* other kinds of filters, and always applied even if a route does not exist.
|
||||
*
|
||||
* Filters set by default provide framework functionality. If removed,
|
||||
* those functions will no longer work.
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/incoming/filters.html#provided-filters
|
||||
*
|
||||
* @var array{before: list<string>, after: list<string>}
|
||||
*/
|
||||
public array $required = [
|
||||
'before' => [
|
||||
'forcehttps', // Force Global Secure Requests
|
||||
'pagecache', // Web Page Caching
|
||||
],
|
||||
'after' => [
|
||||
'pagecache', // Web Page Caching
|
||||
'performance', // Performance Metrics
|
||||
'toolbar', // Debug Toolbar
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* List of filter aliases that are always
|
||||
* applied before and after every request.
|
||||
*
|
||||
* @var array<string, array<string, array<string, string>>>|array<string, list<string>>
|
||||
*/
|
||||
public array $globals = [
|
||||
'before' => [
|
||||
'honeypot',
|
||||
//'csrf' => ['except' => 'login'], //TODO: Temporarily disable CSRF until we get everything sorted.
|
||||
'invalidchars',
|
||||
],
|
||||
'after' => [
|
||||
'toolbar',
|
||||
'honeypot',
|
||||
'secureheaders',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* List of filter aliases that works on a
|
||||
* particular HTTP method (GET, POST, etc.).
|
||||
*
|
||||
* Example:
|
||||
* 'POST' => ['foo', 'bar']
|
||||
*
|
||||
* If you use this, you should disable auto-routing because auto-routing
|
||||
* permits any HTTP method to access a controller. Accessing the controller
|
||||
* with a method you don't expect could bypass the filter.
|
||||
*
|
||||
* @var array<string, list<string>>
|
||||
*/
|
||||
public array $methods = [];
|
||||
|
||||
/**
|
||||
* List of filter aliases that should run on any
|
||||
* before or after URI patterns.
|
||||
*
|
||||
* Example:
|
||||
* 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
|
||||
*
|
||||
* @var array<string, array<string, list<string>>>
|
||||
*/
|
||||
public array $filters = [];
|
||||
}
|
||||
12
app/Config/ForeignCharacters.php
Normal file
12
app/Config/ForeignCharacters.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\ForeignCharacters as BaseForeignCharacters;
|
||||
|
||||
/**
|
||||
* @immutable
|
||||
*/
|
||||
class ForeignCharacters extends BaseForeignCharacters
|
||||
{
|
||||
}
|
||||
77
app/Config/Format.php
Normal file
77
app/Config/Format.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Format\FormatterInterface;
|
||||
use CodeIgniter\Format\JSONFormatter;
|
||||
use CodeIgniter\Format\XMLFormatter;
|
||||
|
||||
class Format extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Available Response Formats
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* When you perform content negotiation with the request, these are the
|
||||
* available formats that your application supports. This is currently
|
||||
* only used with the API\ResponseTrait. A valid Formatter must exist
|
||||
* for the specified format.
|
||||
*
|
||||
* These formats are only checked when the data passed to the respond()
|
||||
* method is an array.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $supportedResponseFormats = [
|
||||
'application/json',
|
||||
'application/xml', // machine-readable XML
|
||||
'text/xml', // human-readable XML
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Formatters
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Lists the class to use to format responses with of a particular type.
|
||||
* For each mime type, list the class that should be used. Formatters
|
||||
* can be retrieved through the getFormatter() method.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $formatters = [
|
||||
'application/json' => JSONFormatter::class,
|
||||
'application/xml' => XMLFormatter::class,
|
||||
'text/xml' => XMLFormatter::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Formatters Options
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Additional Options to adjust default formatters behaviour.
|
||||
* For each mime type, list the additional options that should be used.
|
||||
*
|
||||
* @var array<string, int>
|
||||
*/
|
||||
public array $formatterOptions = [
|
||||
'application/json' => JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
|
||||
'application/xml' => 0,
|
||||
'text/xml' => 0,
|
||||
];
|
||||
|
||||
/**
|
||||
* A Factory method to return the appropriate formatter for the given mime type.
|
||||
*
|
||||
* @return FormatterInterface
|
||||
*
|
||||
* @deprecated This is an alias of `\CodeIgniter\Format\Format::getFormatter`. Use that instead.
|
||||
*/
|
||||
public function getFormatter(string $mime)
|
||||
{
|
||||
return Services::format()->getFormatter($mime);
|
||||
}
|
||||
}
|
||||
44
app/Config/Generators.php
Normal file
44
app/Config/Generators.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Generators extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Generator Commands' Views
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This array defines the mapping of generator commands to the view files
|
||||
* they are using. If you need to customize them for your own, copy these
|
||||
* view files in your own folder and indicate the location here.
|
||||
*
|
||||
* You will notice that the views have special placeholders enclosed in
|
||||
* curly braces `{...}`. These placeholders are used internally by the
|
||||
* generator commands in processing replacements, thus you are warned
|
||||
* not to delete them or modify the names. If you will do so, you may
|
||||
* end up disrupting the scaffolding process and throw errors.
|
||||
*
|
||||
* YOU HAVE BEEN WARNED!
|
||||
*
|
||||
* @var array<string, array<string, string>|string>
|
||||
*/
|
||||
public array $views = [
|
||||
'make:cell' => [
|
||||
'class' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php',
|
||||
'view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php',
|
||||
],
|
||||
'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php',
|
||||
'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php',
|
||||
'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php',
|
||||
'make:entity' => 'CodeIgniter\Commands\Generators\Views\entity.tpl.php',
|
||||
'make:filter' => 'CodeIgniter\Commands\Generators\Views\filter.tpl.php',
|
||||
'make:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
|
||||
'make:model' => 'CodeIgniter\Commands\Generators\Views\model.tpl.php',
|
||||
'make:seeder' => 'CodeIgniter\Commands\Generators\Views\seeder.tpl.php',
|
||||
'make:validation' => 'CodeIgniter\Commands\Generators\Views\validation.tpl.php',
|
||||
'session:migration' => 'CodeIgniter\Commands\Generators\Views\migration.tpl.php',
|
||||
];
|
||||
}
|
||||
42
app/Config/Honeypot.php
Normal file
42
app/Config/Honeypot.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Honeypot extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Makes Honeypot visible or not to human
|
||||
*/
|
||||
public bool $hidden = true;
|
||||
|
||||
/**
|
||||
* Honeypot Label Content
|
||||
*/
|
||||
public string $label = 'Fill This Field';
|
||||
|
||||
/**
|
||||
* Honeypot Field Name
|
||||
*/
|
||||
public string $name = 'honeypot';
|
||||
|
||||
/**
|
||||
* Honeypot HTML Template
|
||||
*/
|
||||
public string $template = '<label>{label}</label><input type="text" name="{name}" value="">';
|
||||
|
||||
/**
|
||||
* Honeypot container
|
||||
*
|
||||
* If you enabled CSP, you can remove `style="display:none"`.
|
||||
*/
|
||||
public string $container = '<div style="display:none">{template}</div>';
|
||||
|
||||
/**
|
||||
* The id attribute for Honeypot container tag
|
||||
*
|
||||
* Used when CSP is enabled.
|
||||
*/
|
||||
public string $containerId = 'hpc';
|
||||
}
|
||||
31
app/Config/Images.php
Normal file
31
app/Config/Images.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Images\Handlers\GDHandler;
|
||||
use CodeIgniter\Images\Handlers\ImageMagickHandler;
|
||||
|
||||
class Images extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* Default handler used if no other handler is specified.
|
||||
*/
|
||||
public string $defaultHandler = 'gd';
|
||||
|
||||
/**
|
||||
* The path to the image library.
|
||||
* Required for ImageMagick, GraphicsMagick, or NetPBM.
|
||||
*/
|
||||
public string $libraryPath = '/usr/local/bin/convert';
|
||||
|
||||
/**
|
||||
* The available handler classes.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $handlers = [
|
||||
'gd' => GDHandler::class,
|
||||
'imagick' => ImageMagickHandler::class,
|
||||
];
|
||||
}
|
||||
65
app/Config/Kint.php
Normal file
65
app/Config/Kint.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use Kint\Parser\ConstructablePluginInterface;
|
||||
use Kint\Renderer\AbstractRenderer;
|
||||
use Kint\Renderer\Rich\TabPluginInterface;
|
||||
use Kint\Renderer\Rich\ValuePluginInterface;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Kint
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* We use Kint's `RichRenderer` and `CLIRenderer`. This area contains options
|
||||
* that you can set to customize how Kint works for you.
|
||||
*
|
||||
* @see https://kint-php.github.io/kint/ for details on these settings.
|
||||
*/
|
||||
class Kint
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Global Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>|null
|
||||
*/
|
||||
public $plugins;
|
||||
|
||||
public int $maxDepth = 6;
|
||||
public bool $displayCalledFrom = true;
|
||||
public bool $expanded = false;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| RichRenderer Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public string $richTheme = 'aante-light.css';
|
||||
public bool $richFolder = false;
|
||||
public int $richSort = AbstractRenderer::SORT_FULL;
|
||||
|
||||
/**
|
||||
* @var array<string, class-string<ValuePluginInterface>>|null
|
||||
*/
|
||||
public $richObjectPlugins;
|
||||
|
||||
/**
|
||||
* @var array<string, class-string<TabPluginInterface>>|null
|
||||
*/
|
||||
public $richTabPlugins;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CLI Settings
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
public bool $cliColors = true;
|
||||
public bool $cliForceUTF8 = false;
|
||||
public bool $cliDetectWidth = true;
|
||||
public int $cliMinWidth = 40;
|
||||
}
|
||||
150
app/Config/Logger.php
Normal file
150
app/Config/Logger.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Log\Handlers\FileHandler;
|
||||
|
||||
class Logger extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Error Logging Threshold
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* You can enable error logging by setting a threshold over zero. The
|
||||
* threshold determines what gets logged. Any values below or equal to the
|
||||
* threshold will be logged.
|
||||
*
|
||||
* Threshold options are:
|
||||
*
|
||||
* - 0 = Disables logging, Error logging TURNED OFF
|
||||
* - 1 = Emergency Messages - System is unusable
|
||||
* - 2 = Alert Messages - Action Must Be Taken Immediately
|
||||
* - 3 = Critical Messages - Application component unavailable, unexpected exception.
|
||||
* - 4 = Runtime Errors - Don't need immediate action, but should be monitored.
|
||||
* - 5 = Warnings - Exceptional occurrences that are not errors.
|
||||
* - 6 = Notices - Normal but significant events.
|
||||
* - 7 = Info - Interesting events, like user logging in, etc.
|
||||
* - 8 = Debug - Detailed debug information.
|
||||
* - 9 = All Messages
|
||||
*
|
||||
* You can also pass an array with threshold levels to show individual error types
|
||||
*
|
||||
* array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages
|
||||
*
|
||||
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise
|
||||
* your log files will fill up very fast.
|
||||
*
|
||||
* @var int|list<int>
|
||||
*/
|
||||
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Date Format for Logs
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Each item that is logged has an associated date. You can use PHP date
|
||||
* codes to set your own date formatting
|
||||
*/
|
||||
public string $dateFormat = 'Y-m-d H:i:s';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Log Handlers
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The logging system supports multiple actions to be taken when something
|
||||
* is logged. This is done by allowing for multiple Handlers, special classes
|
||||
* designed to write the log to their chosen destinations, whether that is
|
||||
* a file on the getServer, a cloud-based service, or even taking actions such
|
||||
* as emailing the dev team.
|
||||
*
|
||||
* Each handler is defined by the class name used for that handler, and it
|
||||
* MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface.
|
||||
*
|
||||
* The value of each key is an array of configuration items that are sent
|
||||
* to the constructor of each handler. The only required configuration item
|
||||
* is the 'handles' element, which must be an array of integer log levels.
|
||||
* This is most easily handled by using the constants defined in the
|
||||
* `Psr\Log\LogLevel` class.
|
||||
*
|
||||
* Handlers are executed in the order defined in this array, starting with
|
||||
* the handler on top and continuing down.
|
||||
*
|
||||
* @var array<class-string, array<string, int|list<string>|string>>
|
||||
*/
|
||||
public array $handlers = [
|
||||
/*
|
||||
* --------------------------------------------------------------------
|
||||
* File Handler
|
||||
* --------------------------------------------------------------------
|
||||
*/
|
||||
FileHandler::class => [
|
||||
// The log levels that this handler will handle.
|
||||
'handles' => [
|
||||
'critical',
|
||||
'alert',
|
||||
'emergency',
|
||||
'debug',
|
||||
'error',
|
||||
'info',
|
||||
'notice',
|
||||
'warning',
|
||||
],
|
||||
|
||||
/*
|
||||
* The default filename extension for log files.
|
||||
* An extension of 'php' allows for protecting the log files via basic
|
||||
* scripting, when they are to be stored under a publicly accessible directory.
|
||||
*
|
||||
* NOTE: Leaving it blank will default to 'log'.
|
||||
*/
|
||||
'fileExtension' => '',
|
||||
|
||||
/*
|
||||
* The file system permissions to be applied on newly created log files.
|
||||
*
|
||||
* IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
|
||||
* integer notation (i.e. 0700, 0644, etc.)
|
||||
*/
|
||||
'filePermissions' => 0660,
|
||||
|
||||
/*
|
||||
* Logging Directory Path
|
||||
*
|
||||
* By default, logs are written to WRITEPATH . 'logs/'
|
||||
* Specify a different destination here, if desired.
|
||||
*/
|
||||
'path' => '',
|
||||
],
|
||||
|
||||
/*
|
||||
* The ChromeLoggerHandler requires the use of the Chrome web browser
|
||||
* and the ChromeLogger extension. Uncomment this block to use it.
|
||||
*/
|
||||
// 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [
|
||||
// /*
|
||||
// * The log levels that this handler will handle.
|
||||
// */
|
||||
// 'handles' => ['critical', 'alert', 'emergency', 'debug',
|
||||
// 'error', 'info', 'notice', 'warning'],
|
||||
// ],
|
||||
|
||||
/*
|
||||
* The ErrorlogHandler writes the logs to PHP's native `error_log()` function.
|
||||
* Uncomment this block to use it.
|
||||
*/
|
||||
// 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [
|
||||
// /* The log levels this handler can handle. */
|
||||
// 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'],
|
||||
//
|
||||
// /*
|
||||
// * The message type where the error should go. Can be 0 or 4, or use the
|
||||
// * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4)
|
||||
// */
|
||||
// 'messageType' => 0,
|
||||
// ],
|
||||
];
|
||||
}
|
||||
50
app/Config/Migrations.php
Normal file
50
app/Config/Migrations.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Migrations extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Enable/Disable Migrations
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Migrations are enabled by default.
|
||||
*
|
||||
* You should enable migrations whenever you intend to do a schema migration
|
||||
* and disable it back when you're done.
|
||||
*/
|
||||
public bool $enabled = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Migrations Table
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is the name of the table that will store the current migrations state.
|
||||
* When migrations runs it will store in a database table which migration
|
||||
* files have already been run.
|
||||
*/
|
||||
public string $table = 'migrations';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Timestamp Format
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is the format that will be used when creating new migrations
|
||||
* using the CLI command:
|
||||
* > php spark make:migration
|
||||
*
|
||||
* NOTE: if you set an unsupported format, migration runner will not find
|
||||
* your migration files.
|
||||
*
|
||||
* Supported formats:
|
||||
* - YmdHis_
|
||||
* - Y-m-d-His_
|
||||
* - Y_m_d_His_
|
||||
*/
|
||||
public string $timestampFormat = 'YmdHis_';
|
||||
}
|
||||
537
app/Config/Mimes.php
Normal file
537
app/Config/Mimes.php
Normal file
@@ -0,0 +1,537 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Mimes
|
||||
*
|
||||
* This file contains an array of mime types. It is used by the
|
||||
* Upload class to help identify allowed file types.
|
||||
*
|
||||
* When more than one variation for an extension exist (like jpg, jpeg, etc)
|
||||
* the most common one should be first in the array to aid the guess*
|
||||
* methods. The same applies when more than one mime-type exists for a
|
||||
* single extension.
|
||||
*
|
||||
* When working with mime types, please make sure you have the ´fileinfo´
|
||||
* extension enabled to reliably detect the media types.
|
||||
*
|
||||
* @immutable
|
||||
*/
|
||||
class Mimes
|
||||
{
|
||||
/**
|
||||
* Map of extensions to mime types.
|
||||
*
|
||||
* @var array<string, list<string>|string>
|
||||
*/
|
||||
public static array $mimes = [
|
||||
'hqx' => [
|
||||
'application/mac-binhex40',
|
||||
'application/mac-binhex',
|
||||
'application/x-binhex40',
|
||||
'application/x-mac-binhex40',
|
||||
],
|
||||
'cpt' => 'application/mac-compactpro',
|
||||
'csv' => [
|
||||
'text/csv',
|
||||
'text/x-comma-separated-values',
|
||||
'text/comma-separated-values',
|
||||
'application/vnd.ms-excel',
|
||||
'application/x-csv',
|
||||
'text/x-csv',
|
||||
'application/csv',
|
||||
'application/excel',
|
||||
'application/vnd.msexcel',
|
||||
'text/plain',
|
||||
],
|
||||
'bin' => [
|
||||
'application/macbinary',
|
||||
'application/mac-binary',
|
||||
'application/octet-stream',
|
||||
'application/x-binary',
|
||||
'application/x-macbinary',
|
||||
],
|
||||
'dms' => 'application/octet-stream',
|
||||
'lha' => 'application/octet-stream',
|
||||
'lzh' => 'application/octet-stream',
|
||||
'exe' => [
|
||||
'application/octet-stream',
|
||||
'application/vnd.microsoft.portable-executable',
|
||||
'application/x-dosexec',
|
||||
'application/x-msdownload',
|
||||
],
|
||||
'class' => 'application/octet-stream',
|
||||
'psd' => [
|
||||
'application/x-photoshop',
|
||||
'image/vnd.adobe.photoshop',
|
||||
],
|
||||
'so' => 'application/octet-stream',
|
||||
'sea' => 'application/octet-stream',
|
||||
'dll' => 'application/octet-stream',
|
||||
'oda' => 'application/oda',
|
||||
'pdf' => [
|
||||
'application/pdf',
|
||||
'application/force-download',
|
||||
'application/x-download',
|
||||
],
|
||||
'ai' => [
|
||||
'application/pdf',
|
||||
'application/postscript',
|
||||
],
|
||||
'eps' => 'application/postscript',
|
||||
'ps' => 'application/postscript',
|
||||
'smi' => 'application/smil',
|
||||
'smil' => 'application/smil',
|
||||
'mif' => 'application/vnd.mif',
|
||||
'xls' => [
|
||||
'application/vnd.ms-excel',
|
||||
'application/msexcel',
|
||||
'application/x-msexcel',
|
||||
'application/x-ms-excel',
|
||||
'application/x-excel',
|
||||
'application/x-dos_ms_excel',
|
||||
'application/xls',
|
||||
'application/x-xls',
|
||||
'application/excel',
|
||||
'application/download',
|
||||
'application/vnd.ms-office',
|
||||
'application/msword',
|
||||
],
|
||||
'ppt' => [
|
||||
'application/vnd.ms-powerpoint',
|
||||
'application/powerpoint',
|
||||
'application/vnd.ms-office',
|
||||
'application/msword',
|
||||
],
|
||||
'pptx' => [
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
],
|
||||
'wbxml' => 'application/wbxml',
|
||||
'wmlc' => 'application/wmlc',
|
||||
'dcr' => 'application/x-director',
|
||||
'dir' => 'application/x-director',
|
||||
'dxr' => 'application/x-director',
|
||||
'dvi' => 'application/x-dvi',
|
||||
'gtar' => 'application/x-gtar',
|
||||
'gz' => 'application/x-gzip',
|
||||
'gzip' => 'application/x-gzip',
|
||||
'php' => [
|
||||
'application/x-php',
|
||||
'application/x-httpd-php',
|
||||
'application/php',
|
||||
'text/php',
|
||||
'text/x-php',
|
||||
'application/x-httpd-php-source',
|
||||
],
|
||||
'php4' => 'application/x-httpd-php',
|
||||
'php3' => 'application/x-httpd-php',
|
||||
'phtml' => 'application/x-httpd-php',
|
||||
'phps' => 'application/x-httpd-php-source',
|
||||
'js' => [
|
||||
'application/x-javascript',
|
||||
'text/plain',
|
||||
],
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'sit' => 'application/x-stuffit',
|
||||
'tar' => 'application/x-tar',
|
||||
'tgz' => [
|
||||
'application/x-tar',
|
||||
'application/x-gzip-compressed',
|
||||
],
|
||||
'z' => 'application/x-compress',
|
||||
'xhtml' => 'application/xhtml+xml',
|
||||
'xht' => 'application/xhtml+xml',
|
||||
'zip' => [
|
||||
'application/x-zip',
|
||||
'application/zip',
|
||||
'application/x-zip-compressed',
|
||||
'application/s-compressed',
|
||||
'multipart/x-zip',
|
||||
],
|
||||
'rar' => [
|
||||
'application/vnd.rar',
|
||||
'application/x-rar',
|
||||
'application/rar',
|
||||
'application/x-rar-compressed',
|
||||
],
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'mpga' => 'audio/mpeg',
|
||||
'mp2' => 'audio/mpeg',
|
||||
'mp3' => [
|
||||
'audio/mpeg',
|
||||
'audio/mpg',
|
||||
'audio/mpeg3',
|
||||
'audio/mp3',
|
||||
],
|
||||
'aif' => [
|
||||
'audio/x-aiff',
|
||||
'audio/aiff',
|
||||
],
|
||||
'aiff' => [
|
||||
'audio/x-aiff',
|
||||
'audio/aiff',
|
||||
],
|
||||
'aifc' => 'audio/x-aiff',
|
||||
'ram' => 'audio/x-pn-realaudio',
|
||||
'rm' => 'audio/x-pn-realaudio',
|
||||
'rpm' => 'audio/x-pn-realaudio-plugin',
|
||||
'ra' => 'audio/x-realaudio',
|
||||
'rv' => 'video/vnd.rn-realvideo',
|
||||
'wav' => [
|
||||
'audio/x-wav',
|
||||
'audio/wave',
|
||||
'audio/wav',
|
||||
],
|
||||
'bmp' => [
|
||||
'image/bmp',
|
||||
'image/x-bmp',
|
||||
'image/x-bitmap',
|
||||
'image/x-xbitmap',
|
||||
'image/x-win-bitmap',
|
||||
'image/x-windows-bmp',
|
||||
'image/ms-bmp',
|
||||
'image/x-ms-bmp',
|
||||
'application/bmp',
|
||||
'application/x-bmp',
|
||||
'application/x-win-bitmap',
|
||||
],
|
||||
'gif' => 'image/gif',
|
||||
'jpg' => [
|
||||
'image/jpeg',
|
||||
'image/pjpeg',
|
||||
],
|
||||
'jpeg' => [
|
||||
'image/jpeg',
|
||||
'image/pjpeg',
|
||||
],
|
||||
'jpe' => [
|
||||
'image/jpeg',
|
||||
'image/pjpeg',
|
||||
],
|
||||
'jp2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'j2k' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpf' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpg2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpx' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'jpm' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'mj2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'mjp2' => [
|
||||
'image/jp2',
|
||||
'video/mj2',
|
||||
'image/jpx',
|
||||
'image/jpm',
|
||||
],
|
||||
'png' => [
|
||||
'image/png',
|
||||
'image/x-png',
|
||||
],
|
||||
'webp' => 'image/webp',
|
||||
'tif' => 'image/tiff',
|
||||
'tiff' => 'image/tiff',
|
||||
'css' => [
|
||||
'text/css',
|
||||
'text/plain',
|
||||
],
|
||||
'html' => [
|
||||
'text/html',
|
||||
'text/plain',
|
||||
],
|
||||
'htm' => [
|
||||
'text/html',
|
||||
'text/plain',
|
||||
],
|
||||
'shtml' => [
|
||||
'text/html',
|
||||
'text/plain',
|
||||
],
|
||||
'txt' => 'text/plain',
|
||||
'text' => 'text/plain',
|
||||
'log' => [
|
||||
'text/plain',
|
||||
'text/x-log',
|
||||
],
|
||||
'rtx' => 'text/richtext',
|
||||
'rtf' => 'text/rtf',
|
||||
'xml' => [
|
||||
'application/xml',
|
||||
'text/xml',
|
||||
'text/plain',
|
||||
],
|
||||
'xsl' => [
|
||||
'application/xml',
|
||||
'text/xsl',
|
||||
'text/xml',
|
||||
],
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpe' => 'video/mpeg',
|
||||
'qt' => 'video/quicktime',
|
||||
'mov' => 'video/quicktime',
|
||||
'avi' => [
|
||||
'video/x-msvideo',
|
||||
'video/msvideo',
|
||||
'video/avi',
|
||||
'application/x-troff-msvideo',
|
||||
],
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'doc' => [
|
||||
'application/msword',
|
||||
'application/vnd.ms-office',
|
||||
],
|
||||
'docx' => [
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/zip',
|
||||
'application/msword',
|
||||
'application/x-zip',
|
||||
],
|
||||
'dot' => [
|
||||
'application/msword',
|
||||
'application/vnd.ms-office',
|
||||
],
|
||||
'dotx' => [
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/zip',
|
||||
'application/msword',
|
||||
],
|
||||
'xlsx' => [
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/zip',
|
||||
'application/vnd.ms-excel',
|
||||
'application/msword',
|
||||
'application/x-zip',
|
||||
],
|
||||
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
|
||||
'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12',
|
||||
'word' => [
|
||||
'application/msword',
|
||||
'application/octet-stream',
|
||||
],
|
||||
'xl' => 'application/excel',
|
||||
'eml' => 'message/rfc822',
|
||||
'json' => [
|
||||
'application/json',
|
||||
'text/json',
|
||||
],
|
||||
'pem' => [
|
||||
'application/x-x509-user-cert',
|
||||
'application/x-pem-file',
|
||||
'application/octet-stream',
|
||||
],
|
||||
'p10' => [
|
||||
'application/x-pkcs10',
|
||||
'application/pkcs10',
|
||||
],
|
||||
'p12' => 'application/x-pkcs12',
|
||||
'p7a' => 'application/x-pkcs7-signature',
|
||||
'p7c' => [
|
||||
'application/pkcs7-mime',
|
||||
'application/x-pkcs7-mime',
|
||||
],
|
||||
'p7m' => [
|
||||
'application/pkcs7-mime',
|
||||
'application/x-pkcs7-mime',
|
||||
],
|
||||
'p7r' => 'application/x-pkcs7-certreqresp',
|
||||
'p7s' => 'application/pkcs7-signature',
|
||||
'crt' => [
|
||||
'application/x-x509-ca-cert',
|
||||
'application/x-x509-user-cert',
|
||||
'application/pkix-cert',
|
||||
],
|
||||
'crl' => [
|
||||
'application/pkix-crl',
|
||||
'application/pkcs-crl',
|
||||
],
|
||||
'der' => 'application/x-x509-ca-cert',
|
||||
'kdb' => 'application/octet-stream',
|
||||
'pgp' => 'application/pgp',
|
||||
'gpg' => 'application/gpg-keys',
|
||||
'sst' => 'application/octet-stream',
|
||||
'csr' => 'application/octet-stream',
|
||||
'rsa' => 'application/x-pkcs7',
|
||||
'cer' => [
|
||||
'application/pkix-cert',
|
||||
'application/x-x509-ca-cert',
|
||||
],
|
||||
'3g2' => 'video/3gpp2',
|
||||
'3gp' => [
|
||||
'video/3gp',
|
||||
'video/3gpp',
|
||||
],
|
||||
'mp4' => 'video/mp4',
|
||||
'm4a' => 'audio/x-m4a',
|
||||
'f4v' => [
|
||||
'video/mp4',
|
||||
'video/x-f4v',
|
||||
],
|
||||
'flv' => 'video/x-flv',
|
||||
'webm' => 'video/webm',
|
||||
'aac' => 'audio/x-acc',
|
||||
'm4u' => 'application/vnd.mpegurl',
|
||||
'm3u' => 'text/plain',
|
||||
'xspf' => 'application/xspf+xml',
|
||||
'vlc' => 'application/videolan',
|
||||
'wmv' => [
|
||||
'video/x-ms-wmv',
|
||||
'video/x-ms-asf',
|
||||
],
|
||||
'au' => 'audio/x-au',
|
||||
'ac3' => 'audio/ac3',
|
||||
'flac' => 'audio/x-flac',
|
||||
'ogg' => [
|
||||
'audio/ogg',
|
||||
'video/ogg',
|
||||
'application/ogg',
|
||||
],
|
||||
'kmz' => [
|
||||
'application/vnd.google-earth.kmz',
|
||||
'application/zip',
|
||||
'application/x-zip',
|
||||
],
|
||||
'kml' => [
|
||||
'application/vnd.google-earth.kml+xml',
|
||||
'application/xml',
|
||||
'text/xml',
|
||||
],
|
||||
'ics' => 'text/calendar',
|
||||
'ical' => 'text/calendar',
|
||||
'zsh' => 'text/x-scriptzsh',
|
||||
'7zip' => [
|
||||
'application/x-compressed',
|
||||
'application/x-zip-compressed',
|
||||
'application/zip',
|
||||
'multipart/x-zip',
|
||||
],
|
||||
'cdr' => [
|
||||
'application/cdr',
|
||||
'application/coreldraw',
|
||||
'application/x-cdr',
|
||||
'application/x-coreldraw',
|
||||
'image/cdr',
|
||||
'image/x-cdr',
|
||||
'zz-application/zz-winassoc-cdr',
|
||||
],
|
||||
'wma' => [
|
||||
'audio/x-ms-wma',
|
||||
'video/x-ms-asf',
|
||||
],
|
||||
'jar' => [
|
||||
'application/java-archive',
|
||||
'application/x-java-application',
|
||||
'application/x-jar',
|
||||
'application/x-compressed',
|
||||
],
|
||||
'svg' => [
|
||||
'image/svg+xml',
|
||||
'image/svg',
|
||||
'application/xml',
|
||||
'text/xml',
|
||||
],
|
||||
'vcf' => 'text/x-vcard',
|
||||
'srt' => [
|
||||
'text/srt',
|
||||
'text/plain',
|
||||
],
|
||||
'vtt' => [
|
||||
'text/vtt',
|
||||
'text/plain',
|
||||
],
|
||||
'ico' => [
|
||||
'image/x-icon',
|
||||
'image/x-ico',
|
||||
'image/vnd.microsoft.icon',
|
||||
],
|
||||
'stl' => [
|
||||
'application/sla',
|
||||
'application/vnd.ms-pki.stl',
|
||||
'application/x-navistyle',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Attempts to determine the best mime type for the given file extension.
|
||||
*
|
||||
* @return string|null The mime type found, or none if unable to determine.
|
||||
*/
|
||||
public static function guessTypeFromExtension(string $extension): array|string|null
|
||||
{
|
||||
$extension = trim(strtolower($extension), '. ');
|
||||
|
||||
if (!array_key_exists($extension, static::$mimes))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return is_array(static::$mimes[$extension]) ? static::$mimes[$extension][0] : static::$mimes[$extension];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to determine the best file extension for a given mime type.
|
||||
*
|
||||
* @param string|null $proposedExtension - default extension (in case there is more than one with the same mime type)
|
||||
*
|
||||
* @return string|null The extension determined, or null if unable to match.
|
||||
*/
|
||||
public static function guessExtensionFromType(string $type, ?string $proposedExtension = null): ?string
|
||||
{
|
||||
$type = trim(strtolower($type), '. ');
|
||||
|
||||
$proposedExtension = trim(strtolower($proposedExtension ?? ''));
|
||||
|
||||
if (
|
||||
$proposedExtension !== ''
|
||||
&& array_key_exists($proposedExtension, static::$mimes)
|
||||
&& in_array($type, (array) static::$mimes[$proposedExtension], true)
|
||||
) {
|
||||
// The detected mime type matches with the proposed extension.
|
||||
return $proposedExtension;
|
||||
}
|
||||
|
||||
// Reverse check the mime type list if no extension was proposed.
|
||||
// This search is order sensitive!
|
||||
foreach (static::$mimes as $ext => $types) {
|
||||
if (in_array($type, (array) $types, true)) {
|
||||
return $ext;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
84
app/Config/Modules.php
Normal file
84
app/Config/Modules.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Modules\Modules as BaseModules;
|
||||
|
||||
/**
|
||||
* Modules Configuration.
|
||||
*
|
||||
* NOTE: This class is required prior to Autoloader instantiation,
|
||||
* and does not extend BaseConfig.
|
||||
*
|
||||
* @immutable
|
||||
*/
|
||||
class Modules extends BaseModules
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Enable Auto-Discovery?
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If true, then auto-discovery will happen across all elements listed in
|
||||
* $aliases below. If false, no auto-discovery will happen at all,
|
||||
* giving a slight performance boost.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $enabled = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Enable Auto-Discovery Within Composer Packages?
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If true, then auto-discovery will happen across all namespaces loaded
|
||||
* by Composer, as well as the namespaces configured locally.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $discoverInComposer = true;
|
||||
|
||||
/**
|
||||
* The Composer package list for Auto-Discovery
|
||||
* This setting is optional.
|
||||
*
|
||||
* E.g.:
|
||||
* [
|
||||
* 'only' => [
|
||||
* // List up all packages to auto-discover
|
||||
* 'codeigniter4/shield',
|
||||
* ],
|
||||
* ]
|
||||
* or
|
||||
* [
|
||||
* 'exclude' => [
|
||||
* // List up packages to exclude.
|
||||
* 'pestphp/pest',
|
||||
* ],
|
||||
* ]
|
||||
*
|
||||
* @var array{only?: list<string>, exclude?: list<string>}
|
||||
*/
|
||||
public $composerPackages = [];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Auto-Discovery Rules
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Aliases list of all discovery classes that will be active and used during
|
||||
* the current application request.
|
||||
*
|
||||
* If it is not listed, only the base application elements will be used.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public $aliases = [
|
||||
'events',
|
||||
'filters',
|
||||
'registrars',
|
||||
'routes',
|
||||
'services',
|
||||
];
|
||||
}
|
||||
57
app/Config/OSPOS.php
Normal file
57
app/Config/OSPOS.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use App\Models\Appconfig;
|
||||
use CodeIgniter\Cache\CacheInterface;
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* This class holds the configuration options stored from the database so that on launch those settings can be cached
|
||||
* once in memory. The settings are referenced frequently, so there is a significant performance hit to not storing
|
||||
* them.
|
||||
*/
|
||||
class OSPOS extends BaseConfig
|
||||
{
|
||||
public array $settings;
|
||||
public string $commit_sha1 = 'dev'; //TODO: Travis scripts need to be updated to replace this with the commit hash on build
|
||||
private CacheInterface $cache;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->cache = Services::cache();
|
||||
$this->set_settings();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function set_settings(): void
|
||||
{
|
||||
$cache = $this->cache->get('settings');
|
||||
|
||||
if($cache)
|
||||
{
|
||||
$this->settings = decode_array($cache);
|
||||
}
|
||||
else
|
||||
{
|
||||
$appconfig = model(Appconfig::class);
|
||||
foreach($appconfig->get_all()->getResult() as $app_config)
|
||||
{
|
||||
$this->settings[$app_config->key] = $app_config->value;
|
||||
}
|
||||
$this->cache->save('settings', encode_array($this->settings));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function update_settings(): void
|
||||
{
|
||||
$this->cache->delete('settings');
|
||||
$this->set_settings();
|
||||
}
|
||||
}
|
||||
32
app/Config/Optimize.php
Normal file
32
app/Config/Optimize.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Optimization Configuration.
|
||||
*
|
||||
* NOTE: This class does not extend BaseConfig for performance reasons.
|
||||
* So you cannot replace the property values with Environment Variables.
|
||||
*
|
||||
* @immutable
|
||||
*/
|
||||
class Optimize
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Config Caching
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/concepts/factories.html#config-caching
|
||||
*/
|
||||
public bool $configCacheEnabled = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Config Caching
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* @see https://codeigniter.com/user_guide/concepts/autoloader.html#file-locator-caching
|
||||
*/
|
||||
public bool $locatorCacheEnabled = false;
|
||||
}
|
||||
61
app/Config/Pager.php
Normal file
61
app/Config/Pager.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Pager extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Templates
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Pagination links are rendered out using views to configure their
|
||||
* appearance. This array contains aliases and the view names to
|
||||
* use when rendering the links.
|
||||
*
|
||||
* Within each view, the Pager object will be available as $pager,
|
||||
* and the desired group as $pagerGroup;
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $templates = [
|
||||
'default_full' => 'CodeIgniter\Pager\Views\default_full',
|
||||
'default_simple' => 'CodeIgniter\Pager\Views\default_simple',
|
||||
'default_head' => 'CodeIgniter\Pager\Views\default_head',
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Items Per Page
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The default number of results shown in a single page.
|
||||
*/
|
||||
public int $perPage = 20;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Bootstrap 3 pagination links styling
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Source code from http://stackoverflow.com/questions/20088779/bootstrap-3-pagination-with-codeigniter
|
||||
*/
|
||||
public $config = [
|
||||
'full_tag_open' => "<ul class='pagination pagination-sm'>",
|
||||
'full_tag_close' => '</ul>',
|
||||
'num_tag_open' => '<li>',
|
||||
'num_tag_close' => '</li>',
|
||||
'cur_tag_open' => "<li class='disabled'><li class='active'><a href='#'>",
|
||||
'cur_tag_close' => "<span class='sr-only'></span></a></li>",
|
||||
'next_tag_open' => "<li>",
|
||||
'next_tagl_close' => "</li>",
|
||||
'prev_tag_open' => "<li>",
|
||||
'prev_tagl_close' => "</li>",
|
||||
'first_tag_open' => "<li>",
|
||||
'first_tagl_close' => "</li>",
|
||||
'last_tag_open' => "<li>",
|
||||
'last_tagl_close' => "</li>"
|
||||
];
|
||||
}
|
||||
80
app/Config/Paths.php
Normal file
80
app/Config/Paths.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
/**
|
||||
* Paths
|
||||
*
|
||||
* Holds the paths that are used by the system to
|
||||
* locate the main directories, app, system, etc.
|
||||
*
|
||||
* Modifying these allows you to restructure your application,
|
||||
* share a system folder between multiple applications, and more.
|
||||
*
|
||||
* All paths are relative to the project's root folder.
|
||||
*
|
||||
* NOTE: This class is required prior to Autoloader instantiation,
|
||||
* and does not extend BaseConfig.
|
||||
*
|
||||
* @immutable
|
||||
*/
|
||||
class Paths
|
||||
{
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* SYSTEM FOLDER NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This must contain the name of your "system" folder. Include
|
||||
* the path if the folder is not in the same directory as this file.
|
||||
*/
|
||||
public string $systemDirectory = __DIR__ . '/../../vendor/codeigniter4/framework/system';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* APPLICATION FOLDER NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* If you want this front controller to use a different "app"
|
||||
* folder than the default one you can set its name here. The folder
|
||||
* can also be renamed or relocated anywhere on your server. If
|
||||
* you do, use a full server path.
|
||||
*
|
||||
* @see http://codeigniter.com/user_guide/general/managing_apps.html
|
||||
*/
|
||||
public string $appDirectory = __DIR__ . '/..';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* WRITABLE DIRECTORY NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This variable must contain the name of your "writable" directory.
|
||||
* The writable directory allows you to group all directories that
|
||||
* need write permission to a single place that can be tucked away
|
||||
* for maximum security, keeping it out of the app and/or
|
||||
* system directories.
|
||||
*/
|
||||
public string $writableDirectory = __DIR__ . '/../../writable';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* TESTS DIRECTORY NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This variable must contain the name of your "tests" directory.
|
||||
*/
|
||||
public string $testsDirectory = __DIR__ . '/../../tests';
|
||||
|
||||
/**
|
||||
* ---------------------------------------------------------------
|
||||
* VIEW DIRECTORY NAME
|
||||
* ---------------------------------------------------------------
|
||||
*
|
||||
* This variable must contain the name of the directory that
|
||||
* contains the view files used by your application. By
|
||||
* default this is in `app/Views`. This value
|
||||
* is used when no value is provided to `Services::renderer()`.
|
||||
*/
|
||||
public string $viewDirectory = __DIR__ . '/../Views';
|
||||
}
|
||||
28
app/Config/Publisher.php
Normal file
28
app/Config/Publisher.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\Publisher as BasePublisher;
|
||||
|
||||
/**
|
||||
* Publisher Configuration
|
||||
*
|
||||
* Defines basic security restrictions for the Publisher class
|
||||
* to prevent abuse by injecting malicious files into a project.
|
||||
*/
|
||||
class Publisher extends BasePublisher
|
||||
{
|
||||
/**
|
||||
* A list of allowed destinations with a (pseudo-)regex
|
||||
* of allowed files for each destination.
|
||||
* Attempts to publish to directories not in this list will
|
||||
* result in a PublisherException. Files that do no fit the
|
||||
* pattern will cause copy/merge to fail.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public $restrictions = [
|
||||
ROOTPATH => '*',
|
||||
FCPATH => '#\.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i',
|
||||
];
|
||||
}
|
||||
41
app/Config/Routes.php
Normal file
41
app/Config/Routes.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use CodeIgniter\Router\RouteCollection;
|
||||
|
||||
/**
|
||||
* @var RouteCollection $routes
|
||||
*/
|
||||
$routes->setDefaultController('Login');
|
||||
|
||||
$routes->get('/', 'Login::index');
|
||||
$routes->get('login', 'Login::index');
|
||||
$routes->post('login', 'Login::index');
|
||||
|
||||
$routes->add('no_access/index/(:segment)', 'No_access::index/$1');
|
||||
$routes->add('no_access/index/(:segment)/(:segment)', 'No_access::index/$1/$2');
|
||||
|
||||
$routes->add('reports/summary_(:any)/(:any)/(:any)', 'Reports::Summary_$1/$2/$3/$4');
|
||||
$routes->add('reports/summary_expenses_categories', 'Reports::date_input_only');
|
||||
$routes->add('reports/summary_payments', 'Reports::date_input_only');
|
||||
$routes->add('reports/summary_discounts', 'Reports::summary_discounts_input');
|
||||
$routes->add('reports/summary_(:any)', 'Reports::date_input');
|
||||
|
||||
$routes->add('reports/graphical_(:any)/(:any)/(:any)', 'Reports::Graphical_$1/$2/$3/$4');
|
||||
$routes->add('reports/graphical_summary_expenses_categories', 'Reports::date_input_only');
|
||||
$routes->add('reports/graphical_summary_discounts', 'Reports::summary_discounts_input');
|
||||
$routes->add('reports/graphical_(:any)', 'Reports::date_input');
|
||||
|
||||
$routes->add('reports/inventory_(:any)/(:any)', 'Reports::Inventory_$1/$2');
|
||||
$routes->add('reports/inventory_low', 'Reports::inventory_low');
|
||||
$routes->add('reports/inventory_summary', 'Reports::inventory_summary_input');
|
||||
$routes->add('reports/inventory_summary/(:any)/(:any)/(:any)', 'Reports::inventory_summary/$1/$2/$3');
|
||||
|
||||
$routes->add('reports/detailed_(:any)/(:any)/(:any)/(:any)', 'Reports::Detailed_$1/$2/$3/$4');
|
||||
$routes->add('reports/detailed_sales', 'Reports::date_input_sales');
|
||||
$routes->add('reports/detailed_receivings', 'Reports::date_input_recv');
|
||||
|
||||
$routes->add('reports/specific_(:any)/(:any)/(:any)/(:any)', 'Reports::Specific_$1/$2/$3/$4');
|
||||
$routes->add('reports/specific_customers', 'Reports::specific_customer_input');
|
||||
$routes->add('reports/specific_employees', 'Reports::specific_employee_input');
|
||||
$routes->add('reports/specific_discounts', 'Reports::specific_discount_input');
|
||||
$routes->add('reports/specific_suppliers', 'Reports::specific_supplier_input');
|
||||
140
app/Config/Routing.php
Normal file
140
app/Config/Routing.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter 4 framework.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\Routing as BaseRouting;
|
||||
|
||||
/**
|
||||
* Routing configuration
|
||||
*/
|
||||
class Routing extends BaseRouting
|
||||
{
|
||||
/**
|
||||
* For Defined Routes.
|
||||
* An array of files that contain route definitions.
|
||||
* Route files are read in order, with the first match
|
||||
* found taking precedence.
|
||||
*
|
||||
* Default: APPPATH . 'Config/Routes.php'
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $routeFiles = [
|
||||
APPPATH . 'Config/Routes.php',
|
||||
];
|
||||
|
||||
/**
|
||||
* For Defined Routes and Auto Routing.
|
||||
* The default namespace to use for Controllers when no other
|
||||
* namespace has been specified.
|
||||
*
|
||||
* Default: 'App\Controllers'
|
||||
*/
|
||||
public string $defaultNamespace = 'App\Controllers';
|
||||
|
||||
/**
|
||||
* For Auto Routing.
|
||||
* The default controller to use when no other controller has been
|
||||
* specified.
|
||||
*
|
||||
* Default: 'Home'
|
||||
*/
|
||||
public string $defaultController = 'Login';
|
||||
|
||||
/**
|
||||
* For Defined Routes and Auto Routing.
|
||||
* The default method to call on the controller when no other
|
||||
* method has been set in the route.
|
||||
*
|
||||
* Default: 'index'
|
||||
*/
|
||||
public string $defaultMethod = 'index';
|
||||
|
||||
/**
|
||||
* For Auto Routing.
|
||||
* Whether to translate dashes in URIs for controller/method to underscores.
|
||||
* Primarily useful when using the auto-routing.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $translateURIDashes = false;
|
||||
|
||||
/**
|
||||
* Sets the class/method that should be called if routing doesn't
|
||||
* find a match. It can be the controller/method name like: Users::index
|
||||
*
|
||||
* This setting is passed to the Router class and handled there.
|
||||
*
|
||||
* If you want to use a closure, you will have to set it in the
|
||||
* routes file by calling:
|
||||
*
|
||||
* $routes->set404Override(function() {
|
||||
* // Do something here
|
||||
* });
|
||||
*
|
||||
* Example:
|
||||
* public $override404 = 'App\Errors::show404';
|
||||
*/
|
||||
public ?string $override404 = null;
|
||||
|
||||
/**
|
||||
* If TRUE, the system will attempt to match the URI against
|
||||
* Controllers by matching each segment against folders/files
|
||||
* in APPPATH/Controllers, when a match wasn't found against
|
||||
* defined routes.
|
||||
*
|
||||
* If FALSE, will stop searching and do NO automatic routing.
|
||||
*/
|
||||
public bool $autoRoute = true;
|
||||
|
||||
/**
|
||||
* For Defined Routes.
|
||||
* If TRUE, will enable the use of the 'prioritize' option
|
||||
* when defining routes.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $prioritize = false;
|
||||
|
||||
/**
|
||||
* For Defined Routes.
|
||||
* If TRUE, matched multiple URI segments will be passed as one parameter.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $multipleSegmentsOneParam = false;
|
||||
|
||||
/**
|
||||
* For Auto Routing (Improved).
|
||||
* Map of URI segments and namespaces.
|
||||
*
|
||||
* The key is the first URI segment. The value is the controller namespace.
|
||||
* E.g.,
|
||||
* [
|
||||
* 'blog' => 'Acme\Blog\Controllers',
|
||||
* ]
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $moduleRoutes = [];
|
||||
|
||||
/**
|
||||
* For Auto Routing (Improved).
|
||||
* Whether to translate dashes in URIs for controller/method to CamelCase.
|
||||
* E.g., blog-controller -> BlogController
|
||||
*
|
||||
* If you enable this, $translateURIDashes is ignored.
|
||||
*
|
||||
* Default: false
|
||||
*/
|
||||
public bool $translateUriToCamelCase = false;
|
||||
}
|
||||
103
app/Config/Security.php
Normal file
103
app/Config/Security.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Security extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Protection Method
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Protection Method for Cross Site Request Forgery protection.
|
||||
*
|
||||
* @var string 'cookie' or 'session'
|
||||
*/
|
||||
public string $csrfProtection = 'cookie';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Token Randomization
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Randomize the CSRF Token for added security.
|
||||
*/
|
||||
public bool $tokenRandomize = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Token Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Token name for Cross Site Request Forgery protection.
|
||||
*/
|
||||
public string $tokenName = 'csrf_ospos_v4';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Header Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Header name for Cross Site Request Forgery protection.
|
||||
*/
|
||||
public string $headerName = 'X-CSRF-TOKEN';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Cookie Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Cookie name for Cross Site Request Forgery protection.
|
||||
*/
|
||||
public string $cookieName = 'csrf_cookie_ospos_v4';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Expires
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Expiration time for Cross Site Request Forgery protection cookie.
|
||||
*
|
||||
* Defaults to two hours (in seconds).
|
||||
*/
|
||||
public int $expires = 7200;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Regenerate
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Regenerate CSRF Token on every submission.
|
||||
*/
|
||||
public bool $regenerate = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF Redirect
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Redirect to previous page with error on failure.
|
||||
*
|
||||
* @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure
|
||||
*/
|
||||
public bool $redirect = (ENVIRONMENT === 'production');
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* CSRF SameSite
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Setting for CSRF SameSite cookie token.
|
||||
*
|
||||
* Allowed values are: None - Lax - Strict - ''.
|
||||
*
|
||||
* Defaults to `Lax` as recommended in this link:
|
||||
*
|
||||
* @see https://portswigger.net/web-security/csrf/samesite-cookies
|
||||
*
|
||||
* @deprecated `Config\Cookie` $samesite property is used.
|
||||
*/
|
||||
public string $samesite = 'Lax';
|
||||
}
|
||||
52
app/Config/Services.php
Normal file
52
app/Config/Services.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseService;
|
||||
use HTMLPurifier;
|
||||
use HTMLPurifier_Config;
|
||||
|
||||
/**
|
||||
* Services Configuration file.
|
||||
*
|
||||
* Services are simply other classes/libraries that the system uses
|
||||
* to do its job. This is used by CodeIgniter to allow the core of the
|
||||
* framework to be swapped out easily without affecting the usage within
|
||||
* the rest of your application.
|
||||
*
|
||||
* This file holds any application-specific services, or service overrides
|
||||
* that you might need. An example has been included with the general
|
||||
* method format you should use for your service methods. For more examples,
|
||||
* see the core Services file at system/Config/Services.php.
|
||||
*/
|
||||
class Services extends BaseService
|
||||
{
|
||||
/*
|
||||
* public static function example($getShared = true)
|
||||
* {
|
||||
* if ($getShared) {
|
||||
* return static::getSharedInstance('example');
|
||||
* }
|
||||
*
|
||||
* return new \CodeIgniter\Example();
|
||||
* }
|
||||
*/
|
||||
|
||||
private static $htmlPurifier;
|
||||
|
||||
public static function htmlPurifier($getShared = true)
|
||||
{
|
||||
if ($getShared)
|
||||
{
|
||||
return static::getSharedInstance('htmlPurifier');
|
||||
}
|
||||
|
||||
if (!isset(static::$htmlPurifier))
|
||||
{
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
static::$htmlPurifier = new HTMLPurifier($config);
|
||||
}
|
||||
|
||||
return static::$htmlPurifier;
|
||||
}
|
||||
}
|
||||
127
app/Config/Session.php
Normal file
127
app/Config/Session.php
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Session\Handlers\BaseHandler;
|
||||
use CodeIgniter\Session\Handlers\DatabaseHandler;
|
||||
|
||||
class Session extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Driver
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The session storage driver to use:
|
||||
* - `CodeIgniter\Session\Handlers\FileHandler`
|
||||
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
|
||||
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
|
||||
* - `CodeIgniter\Session\Handlers\RedisHandler`
|
||||
*
|
||||
* @var class-string<BaseHandler>
|
||||
*/
|
||||
public string $driver = DatabaseHandler::class;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Cookie Name
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The session cookie name, must contain only [0-9a-z_-] characters
|
||||
*/
|
||||
public string $cookieName = 'ospos_session';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Expiration
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The number of SECONDS you want the session to last.
|
||||
* Setting to 0 (zero) means expire when the browser is closed.
|
||||
*/
|
||||
public int $expiration = 7200;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Save Path
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The location to save sessions to and is driver dependent.
|
||||
*
|
||||
* For the 'files' driver, it's a path to a writable directory.
|
||||
* WARNING: Only absolute paths are supported!
|
||||
*
|
||||
* For the 'database' driver, it's a table name.
|
||||
* Please read up the manual for the format with other session drivers.
|
||||
*
|
||||
* IMPORTANT: You are REQUIRED to set a valid save path!
|
||||
*/
|
||||
public string $savePath = 'sessions';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Match IP
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Whether to match the user's IP address when reading the session data.
|
||||
*
|
||||
* WARNING: If you're using the database driver, don't forget to update
|
||||
* your session table's PRIMARY KEY when changing this setting.
|
||||
*/
|
||||
public bool $matchIP = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Time to Update
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* How many seconds between CI regenerating the session ID.
|
||||
*/
|
||||
public int $timeToUpdate = 300;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Regenerate Destroy
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Whether to destroy session data associated with the old session ID
|
||||
* when auto-regenerating the session ID. When set to FALSE, the data
|
||||
* will be later deleted by the garbage collector.
|
||||
*/
|
||||
public bool $regenerateDestroy = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Session Database Group
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* DB Group for the database session.
|
||||
*/
|
||||
public ?string $DBGroup = null;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Lock Retry Interval (microseconds)
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is used for RedisHandler.
|
||||
*
|
||||
* Time (microseconds) to wait if lock cannot be acquired.
|
||||
* The default is 100,000 microseconds (= 0.1 seconds).
|
||||
*/
|
||||
public int $lockRetryInterval = 100_000;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Lock Max Retries
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* This is used for RedisHandler.
|
||||
*
|
||||
* Maximum number of lock acquisition attempts.
|
||||
* The default is 300 times. That is lock timeout is about 30 (0.1 * 300)
|
||||
* seconds.
|
||||
*/
|
||||
public int $lockMaxRetries = 300;
|
||||
}
|
||||
122
app/Config/Toolbar.php
Normal file
122
app/Config/Toolbar.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Database;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Events;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Files;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Logs;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Routes;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Timers;
|
||||
use CodeIgniter\Debug\Toolbar\Collectors\Views;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Debug Toolbar
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The Debug Toolbar provides a way to see information about the performance
|
||||
* and state of your application during that page display. By default it will
|
||||
* NOT be displayed under production environments, and will only display if
|
||||
* `CI_DEBUG` is true, since if it's not, there's not much to display anyway.
|
||||
*/
|
||||
class Toolbar extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Toolbar Collectors
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* List of toolbar collectors that will be called when Debug Toolbar
|
||||
* fires up and collects data from.
|
||||
*
|
||||
* @var list<class-string>
|
||||
*/
|
||||
public array $collectors = [
|
||||
Timers::class,
|
||||
Database::class,
|
||||
Logs::class,
|
||||
Views::class,
|
||||
// \CodeIgniter\Debug\Toolbar\Collectors\Cache::class,
|
||||
Files::class,
|
||||
Routes::class,
|
||||
Events::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Collect Var Data
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If set to false var data from the views will not be collected. Useful to
|
||||
* avoid high memory usage when there are lots of data passed to the view.
|
||||
*/
|
||||
public bool $collectVarData = true;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Max History
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* `$maxHistory` sets a limit on the number of past requests that are stored,
|
||||
* helping to conserve file space used to store them. You can set it to
|
||||
* 0 (zero) to not have any history stored, or -1 for unlimited history.
|
||||
*/
|
||||
public int $maxHistory = 20;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Toolbar Views Path
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The full path to the the views that are used by the toolbar.
|
||||
* This MUST have a trailing slash.
|
||||
*/
|
||||
public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Max Queries
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* If the Database Collector is enabled, it will log every query that the
|
||||
* the system generates so they can be displayed on the toolbar's timeline
|
||||
* and in the query log. This can lead to memory issues in some instances
|
||||
* with hundreds of queries.
|
||||
*
|
||||
* `$maxQueries` defines the maximum amount of queries that will be stored.
|
||||
*/
|
||||
public int $maxQueries = 100;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Watched Directories
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Contains an array of directories that will be watched for changes and
|
||||
* used to determine if the hot-reload feature should reload the page or not.
|
||||
* We restrict the values to keep performance as high as possible.
|
||||
*
|
||||
* NOTE: The ROOTPATH will be prepended to all values.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $watchedDirectories = [
|
||||
'app',
|
||||
];
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Watched File Extensions
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* Contains an array of file extensions that will be watched for changes and
|
||||
* used to determine if the hot-reload feature should reload the page or not.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $watchedExtensions = [
|
||||
'php', 'css', 'js', 'html', 'svg', 'json', 'env',
|
||||
];
|
||||
}
|
||||
252
app/Config/UserAgents.php
Normal file
252
app/Config/UserAgents.php
Normal file
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* User Agents
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* This file contains four arrays of user agent data. It is used by the
|
||||
* User Agent Class to help identify browser, platform, robot, and
|
||||
* mobile device data. The array keys are used to identify the device
|
||||
* and the array values are used to set the actual name of the item.
|
||||
*/
|
||||
class UserAgents extends BaseConfig
|
||||
{
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* OS Platforms
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $platforms = [
|
||||
'windows nt 10.0' => 'Windows 10',
|
||||
'windows nt 6.3' => 'Windows 8.1',
|
||||
'windows nt 6.2' => 'Windows 8',
|
||||
'windows nt 6.1' => 'Windows 7',
|
||||
'windows nt 6.0' => 'Windows Vista',
|
||||
'windows nt 5.2' => 'Windows 2003',
|
||||
'windows nt 5.1' => 'Windows XP',
|
||||
'windows nt 5.0' => 'Windows 2000',
|
||||
'windows nt 4.0' => 'Windows NT 4.0',
|
||||
'winnt4.0' => 'Windows NT 4.0',
|
||||
'winnt 4.0' => 'Windows NT',
|
||||
'winnt' => 'Windows NT',
|
||||
'windows 98' => 'Windows 98',
|
||||
'win98' => 'Windows 98',
|
||||
'windows 95' => 'Windows 95',
|
||||
'win95' => 'Windows 95',
|
||||
'windows phone' => 'Windows Phone',
|
||||
'windows' => 'Unknown Windows OS',
|
||||
'android' => 'Android',
|
||||
'blackberry' => 'BlackBerry',
|
||||
'iphone' => 'iOS',
|
||||
'ipad' => 'iOS',
|
||||
'ipod' => 'iOS',
|
||||
'os x' => 'Mac OS X',
|
||||
'ppc mac' => 'Power PC Mac',
|
||||
'freebsd' => 'FreeBSD',
|
||||
'ppc' => 'Macintosh',
|
||||
'linux' => 'Linux',
|
||||
'debian' => 'Debian',
|
||||
'sunos' => 'Sun Solaris',
|
||||
'beos' => 'BeOS',
|
||||
'apachebench' => 'ApacheBench',
|
||||
'aix' => 'AIX',
|
||||
'irix' => 'Irix',
|
||||
'osf' => 'DEC OSF',
|
||||
'hp-ux' => 'HP-UX',
|
||||
'netbsd' => 'NetBSD',
|
||||
'bsdi' => 'BSDi',
|
||||
'openbsd' => 'OpenBSD',
|
||||
'gnu' => 'GNU/Linux',
|
||||
'unix' => 'Unknown Unix OS',
|
||||
'symbian' => 'Symbian OS',
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Browsers
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* The order of this array should NOT be changed. Many browsers return
|
||||
* multiple browser types so we want to identify the subtype first.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $browsers = [
|
||||
'OPR' => 'Opera',
|
||||
'Flock' => 'Flock',
|
||||
'Edge' => 'Spartan',
|
||||
'Edg' => 'Edge',
|
||||
'Chrome' => 'Chrome',
|
||||
// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
|
||||
'Opera.*?Version' => 'Opera',
|
||||
'Opera' => 'Opera',
|
||||
'MSIE' => 'Internet Explorer',
|
||||
'Internet Explorer' => 'Internet Explorer',
|
||||
'Trident.* rv' => 'Internet Explorer',
|
||||
'Shiira' => 'Shiira',
|
||||
'Firefox' => 'Firefox',
|
||||
'Chimera' => 'Chimera',
|
||||
'Phoenix' => 'Phoenix',
|
||||
'Firebird' => 'Firebird',
|
||||
'Camino' => 'Camino',
|
||||
'Netscape' => 'Netscape',
|
||||
'OmniWeb' => 'OmniWeb',
|
||||
'Safari' => 'Safari',
|
||||
'Mozilla' => 'Mozilla',
|
||||
'Konqueror' => 'Konqueror',
|
||||
'icab' => 'iCab',
|
||||
'Lynx' => 'Lynx',
|
||||
'Links' => 'Links',
|
||||
'hotjava' => 'HotJava',
|
||||
'amaya' => 'Amaya',
|
||||
'IBrowse' => 'IBrowse',
|
||||
'Maxthon' => 'Maxthon',
|
||||
'Ubuntu' => 'Ubuntu Web Browser',
|
||||
'Vivaldi' => 'Vivaldi',
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Mobiles
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $mobiles = [
|
||||
// legacy array, old values commented out
|
||||
'mobileexplorer' => 'Mobile Explorer',
|
||||
// 'openwave' => 'Open Wave',
|
||||
// 'opera mini' => 'Opera Mini',
|
||||
// 'operamini' => 'Opera Mini',
|
||||
// 'elaine' => 'Palm',
|
||||
'palmsource' => 'Palm',
|
||||
// 'digital paths' => 'Palm',
|
||||
// 'avantgo' => 'Avantgo',
|
||||
// 'xiino' => 'Xiino',
|
||||
'palmscape' => 'Palmscape',
|
||||
// 'nokia' => 'Nokia',
|
||||
// 'ericsson' => 'Ericsson',
|
||||
// 'blackberry' => 'BlackBerry',
|
||||
// 'motorola' => 'Motorola'
|
||||
|
||||
// Phones and Manufacturers
|
||||
'motorola' => 'Motorola',
|
||||
'nokia' => 'Nokia',
|
||||
'palm' => 'Palm',
|
||||
'iphone' => 'Apple iPhone',
|
||||
'ipad' => 'iPad',
|
||||
'ipod' => 'Apple iPod Touch',
|
||||
'sony' => 'Sony Ericsson',
|
||||
'ericsson' => 'Sony Ericsson',
|
||||
'blackberry' => 'BlackBerry',
|
||||
'cocoon' => 'O2 Cocoon',
|
||||
'blazer' => 'Treo',
|
||||
'lg' => 'LG',
|
||||
'amoi' => 'Amoi',
|
||||
'xda' => 'XDA',
|
||||
'mda' => 'MDA',
|
||||
'vario' => 'Vario',
|
||||
'htc' => 'HTC',
|
||||
'samsung' => 'Samsung',
|
||||
'sharp' => 'Sharp',
|
||||
'sie-' => 'Siemens',
|
||||
'alcatel' => 'Alcatel',
|
||||
'benq' => 'BenQ',
|
||||
'ipaq' => 'HP iPaq',
|
||||
'mot-' => 'Motorola',
|
||||
'playstation portable' => 'PlayStation Portable',
|
||||
'playstation 3' => 'PlayStation 3',
|
||||
'playstation vita' => 'PlayStation Vita',
|
||||
'hiptop' => 'Danger Hiptop',
|
||||
'nec-' => 'NEC',
|
||||
'panasonic' => 'Panasonic',
|
||||
'philips' => 'Philips',
|
||||
'sagem' => 'Sagem',
|
||||
'sanyo' => 'Sanyo',
|
||||
'spv' => 'SPV',
|
||||
'zte' => 'ZTE',
|
||||
'sendo' => 'Sendo',
|
||||
'nintendo dsi' => 'Nintendo DSi',
|
||||
'nintendo ds' => 'Nintendo DS',
|
||||
'nintendo 3ds' => 'Nintendo 3DS',
|
||||
'wii' => 'Nintendo Wii',
|
||||
'open web' => 'Open Web',
|
||||
'openweb' => 'OpenWeb',
|
||||
|
||||
// Operating Systems
|
||||
'android' => 'Android',
|
||||
'symbian' => 'Symbian',
|
||||
'SymbianOS' => 'SymbianOS',
|
||||
'elaine' => 'Palm',
|
||||
'series60' => 'Symbian S60',
|
||||
'windows ce' => 'Windows CE',
|
||||
|
||||
// Browsers
|
||||
'obigo' => 'Obigo',
|
||||
'netfront' => 'Netfront Browser',
|
||||
'openwave' => 'Openwave Browser',
|
||||
'mobilexplorer' => 'Mobile Explorer',
|
||||
'operamini' => 'Opera Mini',
|
||||
'opera mini' => 'Opera Mini',
|
||||
'opera mobi' => 'Opera Mobile',
|
||||
'fennec' => 'Firefox Mobile',
|
||||
|
||||
// Other
|
||||
'digital paths' => 'Digital Paths',
|
||||
'avantgo' => 'AvantGo',
|
||||
'xiino' => 'Xiino',
|
||||
'novarra' => 'Novarra Transcoder',
|
||||
'vodafone' => 'Vodafone',
|
||||
'docomo' => 'NTT DoCoMo',
|
||||
'o2' => 'O2',
|
||||
|
||||
// Fallback
|
||||
'mobile' => 'Generic Mobile',
|
||||
'wireless' => 'Generic Mobile',
|
||||
'j2me' => 'Generic Mobile',
|
||||
'midp' => 'Generic Mobile',
|
||||
'cldc' => 'Generic Mobile',
|
||||
'up.link' => 'Generic Mobile',
|
||||
'up.browser' => 'Generic Mobile',
|
||||
'smartphone' => 'Generic Mobile',
|
||||
'cellphone' => 'Generic Mobile',
|
||||
];
|
||||
|
||||
/**
|
||||
* -------------------------------------------------------------------
|
||||
* Robots
|
||||
* -------------------------------------------------------------------
|
||||
*
|
||||
* There are hundred of bots but these are the most common.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $robots = [
|
||||
'googlebot' => 'Googlebot',
|
||||
'msnbot' => 'MSNBot',
|
||||
'baiduspider' => 'Baiduspider',
|
||||
'bingbot' => 'Bing',
|
||||
'slurp' => 'Inktomi Slurp',
|
||||
'yahoo' => 'Yahoo',
|
||||
'ask jeeves' => 'Ask Jeeves',
|
||||
'fastcrawler' => 'FastCrawler',
|
||||
'infoseek' => 'InfoSeek Robot 1.0',
|
||||
'lycos' => 'Lycos',
|
||||
'yandex' => 'YandexBot',
|
||||
'mediapartners-google' => 'MediaPartners Google',
|
||||
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
|
||||
'adsbot-google' => 'AdsBot Google',
|
||||
'feedfetcher-google' => 'Feedfetcher Google',
|
||||
'curious george' => 'Curious George',
|
||||
'ia_archiver' => 'Alexa Crawler',
|
||||
'MJ12bot' => 'Majestic-12',
|
||||
'Uptimebot' => 'Uptimebot',
|
||||
];
|
||||
}
|
||||
46
app/Config/Validation.php
Normal file
46
app/Config/Validation.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use App\Config\Validation\OSPOSRules;
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Validation\StrictRules\CreditCardRules;
|
||||
use CodeIgniter\Validation\StrictRules\FileRules;
|
||||
use CodeIgniter\Validation\StrictRules\FormatRules;
|
||||
use CodeIgniter\Validation\StrictRules\Rules;
|
||||
|
||||
class Validation extends BaseConfig
|
||||
{
|
||||
// --------------------------------------------------------------------
|
||||
// Setup
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Stores the classes that contain the
|
||||
* rules that are available.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public array $ruleSets = [
|
||||
Rules::class,
|
||||
FormatRules::class,
|
||||
FileRules::class,
|
||||
CreditCardRules::class,
|
||||
OSPOSRules::class
|
||||
];
|
||||
|
||||
/**
|
||||
* Specifies the views that are used to display the
|
||||
* errors.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $templates = [
|
||||
'list' => 'CodeIgniter\Validation\Views\list',
|
||||
'single' => 'CodeIgniter\Validation\Views\single',
|
||||
];
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Rules
|
||||
// --------------------------------------------------------------------
|
||||
}
|
||||
162
app/Config/Validation/OSPOSRules.php
Normal file
162
app/Config/Validation/OSPOSRules.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
namespace App\Config\Validation;
|
||||
|
||||
use App\Models\Employee;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* @property Employee employee
|
||||
* @property IncomingRequest request
|
||||
*/
|
||||
class OSPOSRules
|
||||
{
|
||||
private IncomingRequest $request;
|
||||
private array $config;
|
||||
|
||||
/**
|
||||
* Validates the username and password sent to the login view. User is logged in on successful validation.
|
||||
*
|
||||
* @param string $username Username to check against.
|
||||
* @param string $fields Comma separated string of the fields for validation.
|
||||
* @param array $data Data sent to the view.
|
||||
* @param string|null $error The error sent back to the validation handler on failure.
|
||||
* @return bool True if validation passes or false if there are errors.
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function login_check(string $username, string $fields , array $data, ?string &$error = null): bool
|
||||
{
|
||||
$employee = model(Employee::class);
|
||||
$this->request = Services::request();
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
|
||||
//Installation Check
|
||||
if(!$this->installation_check())
|
||||
{
|
||||
$error = lang('Login.invalid_installation');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$password = $data['password'];
|
||||
if(!$employee->login($username, $password))
|
||||
{
|
||||
$error = lang('Login.invalid_username_and_password');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$gcaptcha_enabled = array_key_exists('gcaptcha_enable', $this->config) && $this->config['gcaptcha_enable'];
|
||||
if($gcaptcha_enabled)
|
||||
{
|
||||
$g_recaptcha_response = $this->request->getPost('g-recaptcha-response');
|
||||
|
||||
if(!$this->gcaptcha_check($g_recaptcha_response))
|
||||
{
|
||||
$error = lang('Login.invalid_gcaptcha');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if GCaptcha verification was successful.
|
||||
*
|
||||
* @param $response
|
||||
* @return bool true on successful GCaptcha verification or false if GCaptcha failed.
|
||||
*/
|
||||
private function gcaptcha_check($response): bool
|
||||
{
|
||||
if(!empty($response))
|
||||
{
|
||||
$check = [
|
||||
'secret' => $this->config['gcaptcha_secret_key'],
|
||||
'response' => $response,
|
||||
'remoteip' => $this->request->getIPAddress()
|
||||
];
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($check));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$result = curl_exec($ch);
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
$status = json_decode($result, true);
|
||||
|
||||
if(!empty($status['success']))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to make sure dependency PHP extensions are installed
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function installation_check(): bool
|
||||
{
|
||||
$installed_extensions = implode(', ', get_loaded_extensions());
|
||||
$required_extensions = ['bcmath', 'intl', 'gd', 'openssl', 'mbstring', 'curl'];
|
||||
$pattern = '/';
|
||||
|
||||
foreach($required_extensions as $extension)
|
||||
{
|
||||
$pattern .= '(?=.*\b' . preg_quote($extension, '/') . '\b)';
|
||||
}
|
||||
|
||||
$pattern .= '/i';
|
||||
$is_installed = preg_match($pattern, $installed_extensions);
|
||||
|
||||
if(!$is_installed)
|
||||
{
|
||||
log_message('error', '[ERROR] Check your php.ini.');
|
||||
log_message('error',"PHP installed extensions: $installed_extensions");
|
||||
log_message('error','PHP required extensions: ' . implode(', ', $required_extensions));
|
||||
}
|
||||
|
||||
return $is_installed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the candidate as a decimal number. Takes the locale into account. Used in validation rule calls.
|
||||
*
|
||||
* @param string $candidate
|
||||
* @param string|null $error
|
||||
* @return bool
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function decimal_locale(string $candidate, ?string &$error = null): bool
|
||||
{
|
||||
$candidate = prepare_decimal($candidate);
|
||||
$validation = Services::validation();
|
||||
|
||||
$validation->setRules([
|
||||
'candidate' => 'decimal'
|
||||
]);
|
||||
|
||||
$data = [
|
||||
'candidate' => $candidate
|
||||
];
|
||||
|
||||
if (!$validation->run($data))
|
||||
{
|
||||
$error = $validation->getErrors();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
62
app/Config/View.php
Normal file
62
app/Config/View.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace Config;
|
||||
|
||||
use CodeIgniter\Config\View as BaseView;
|
||||
use CodeIgniter\View\ViewDecoratorInterface;
|
||||
|
||||
/**
|
||||
* @phpstan-type parser_callable (callable(mixed): mixed)
|
||||
* @phpstan-type parser_callable_string (callable(mixed): mixed)&string
|
||||
*/
|
||||
class View extends BaseView
|
||||
{
|
||||
/**
|
||||
* When false, the view method will clear the data between each
|
||||
* call. This keeps your data safe and ensures there is no accidental
|
||||
* leaking between calls, so you would need to explicitly pass the data
|
||||
* to each view. You might prefer to have the data stick around between
|
||||
* calls so that it is available to all views. If that is the case,
|
||||
* set $saveData to true.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $saveData = true;
|
||||
|
||||
/**
|
||||
* Parser Filters map a filter name with any PHP callable. When the
|
||||
* Parser prepares a variable for display, it will chain it
|
||||
* through the filters in the order defined, inserting any parameters.
|
||||
* To prevent potential abuse, all filters MUST be defined here
|
||||
* in order for them to be available for use within the Parser.
|
||||
*
|
||||
* Examples:
|
||||
* { title|esc(js) }
|
||||
* { created_on|date(Y-m-d)|esc(attr) }
|
||||
*
|
||||
* @var array<string, string>
|
||||
* @phpstan-var array<string, parser_callable_string>
|
||||
*/
|
||||
public $filters = [];
|
||||
|
||||
/**
|
||||
* Parser Plugins provide a way to extend the functionality provided
|
||||
* by the core Parser by creating aliases that will be replaced with
|
||||
* any callable. Can be single or tag pair.
|
||||
*
|
||||
* @var array<string, callable|list<string>|string>
|
||||
* @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
|
||||
*/
|
||||
public $plugins = [];
|
||||
|
||||
/**
|
||||
* View Decorators are class methods that will be run in sequence to
|
||||
* have a chance to alter the generated output just prior to caching
|
||||
* the results.
|
||||
*
|
||||
* All classes must implement CodeIgniter\View\ViewDecoratorInterface
|
||||
*
|
||||
* @var list<class-string<ViewDecoratorInterface>>
|
||||
*/
|
||||
public array $decorators = [];
|
||||
}
|
||||
261
app/Controllers/Attributes.php
Normal file
261
app/Controllers/Attributes.php
Normal file
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Attribute;
|
||||
|
||||
require_once('Secure_Controller.php');
|
||||
|
||||
/**
|
||||
* Attributes controls the custom attributes assigned to items
|
||||
**/
|
||||
class Attributes extends Secure_Controller
|
||||
{
|
||||
private Attribute $attribute;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('attributes');
|
||||
|
||||
$this->attribute = model(Attribute::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets and sends the main view for Attributes to the browser.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['table_headers'] = get_attribute_definition_manage_table_headers();
|
||||
|
||||
echo view('attributes/manage', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns attribute table data rows. This will be called with AJAX.
|
||||
*/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$attributes = $this->attribute->search($search, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->attribute->get_found_rows($search);
|
||||
|
||||
$data_rows = [];
|
||||
foreach($attributes->getResult() as $attribute_row)
|
||||
{
|
||||
$attribute_row->definition_flags = $this->get_attributes($attribute_row->definition_flags);
|
||||
$data_rows[] = get_attribute_definition_data_row($attribute_row);
|
||||
}
|
||||
|
||||
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX called function which saves the attribute value sent via POST by using the model save function.
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postSaveAttributeValue(): void
|
||||
{
|
||||
$success = $this->attribute->save_value(
|
||||
html_entity_decode($this->request->getPost('attribute_value')),
|
||||
$this->request->getPost('definition_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
$this->request->getPost('item_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
$this->request->getPost('attribute_id', FILTER_SANITIZE_NUMBER_INT)
|
||||
);
|
||||
|
||||
echo json_encode(['success' => $success != 0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX called function deleting an attribute value using the model delete function.
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postDelete_attribute_value(): void
|
||||
{
|
||||
$success = $this->attribute->delete_value(
|
||||
html_entity_decode($this->request->getPost('attribute_value')),
|
||||
$this->request->getPost('definition_id', FILTER_SANITIZE_NUMBER_INT)
|
||||
);
|
||||
|
||||
echo json_encode(['success' => $success]);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX called function which saves the attribute definition.
|
||||
*
|
||||
* @param int $definition_id
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postSaveDefinition(int $definition_id = NO_DEFINITION_ID): void
|
||||
{
|
||||
$definition_flags = 0;
|
||||
|
||||
$flags = (empty($this->request->getPost('definition_flags'))) ? [] : $this->request->getPost('definition_flags', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
foreach($flags as $flag)
|
||||
{
|
||||
$definition_flags |= $flag;
|
||||
}
|
||||
|
||||
//Save definition data
|
||||
$definition_data = [
|
||||
'definition_name' => $this->request->getPost('definition_name'),
|
||||
'definition_unit' => $this->request->getPost('definition_unit') != '' ? $this->request->getPost('definition_unit') : null,
|
||||
'definition_flags' => $definition_flags,
|
||||
'definition_fk' => $this->request->getPost('definition_group') != '' ? $this->request->getPost('definition_group') : null
|
||||
];
|
||||
|
||||
if ($this->request->getPost('definition_type') != null)
|
||||
{
|
||||
$definition_data['definition_type'] = DEFINITION_TYPES[$this->request->getPost('definition_type')];
|
||||
}
|
||||
|
||||
$definition_name = $definition_data['definition_name'];
|
||||
|
||||
if($this->attribute->save_definition($definition_data, $definition_id))
|
||||
{
|
||||
//New definition
|
||||
if($definition_id == NO_DEFINITION_ID)
|
||||
{
|
||||
$definition_values = json_decode(html_entity_decode($this->request->getPost('definition_values')));
|
||||
|
||||
foreach($definition_values as $definition_value)
|
||||
{
|
||||
$this->attribute->save_value($definition_value, $definition_data['definition_id']);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => lang('Attributes.definition_successful_adding') . ' ' . $definition_name,
|
||||
'id' => $definition_data['definition_id']
|
||||
]);
|
||||
}
|
||||
//Existing definition
|
||||
else
|
||||
{
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => lang('Attributes.definition_successful_updating') . ' ' . $definition_name,
|
||||
'id' => $definition_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
//Failure
|
||||
else
|
||||
{
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => lang('Attributes.definition_error_adding_updating', [$definition_name]),
|
||||
'id' => NEW_ENTRY
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $definition_id
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getSuggestAttribute(int $definition_id): void
|
||||
{
|
||||
$suggestions = $this->attribute->get_suggestions($definition_id, html_entity_decode($this->request->getGet('term')));
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $row_id
|
||||
* @return void
|
||||
*/
|
||||
public function getRow(int $row_id): void
|
||||
{
|
||||
$attribute_definition_info = $this->attribute->get_info($row_id);
|
||||
$attribute_definition_info->definition_flags = $this->get_attributes($attribute_definition_info->definition_flags);
|
||||
$data_row = get_attribute_definition_data_row($attribute_definition_info);
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $definition_flags
|
||||
* @return array
|
||||
*/
|
||||
private function get_attributes(int $definition_flags = 0): array
|
||||
{
|
||||
$definition_flag_names = [];
|
||||
foreach (Attribute::get_definition_flags() as $id => $term)
|
||||
{
|
||||
if ($id & $definition_flags)
|
||||
{
|
||||
$definition_flag_names[$id] = lang('Attributes.' . strtolower($term) . '_visibility');
|
||||
}
|
||||
}
|
||||
return $definition_flag_names;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $definition_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $definition_id = NO_DEFINITION_ID): void
|
||||
{
|
||||
$info = $this->attribute->get_info($definition_id);
|
||||
foreach(get_object_vars($info) as $property => $value)
|
||||
{
|
||||
$info->$property = $value;
|
||||
}
|
||||
|
||||
$data['definition_id'] = $definition_id;
|
||||
$data['definition_values'] = $this->attribute->get_definition_values($definition_id);
|
||||
$data['definition_group'] = $this->attribute->get_definitions_by_type(GROUP, $definition_id);
|
||||
$data['definition_group'][''] = lang('Common.none_selected_text');
|
||||
$data['definition_info'] = $info;
|
||||
|
||||
$show_all = Attribute::SHOW_IN_ITEMS | Attribute::SHOW_IN_RECEIVINGS | Attribute::SHOW_IN_SALES;
|
||||
$data['definition_flags'] = $this->get_attributes($show_all);
|
||||
$selected_flags = $info->definition_flags === '' ? $show_all : $info->definition_flags;
|
||||
$data['selected_definition_flags'] = $this->get_attributes($selected_flags);
|
||||
|
||||
echo view('attributes/form', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX called function to delete an attribute value. This is never called in the code. Perhaps it was boiler plate code that just isn't needed?
|
||||
* @param int $attribute_id
|
||||
* @return bool
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function delete_value(int $attribute_id): bool //TODO: This function appears to never be used in the codebase. Is it needed?
|
||||
{
|
||||
return $this->attribute->delete_value($attribute_id, NO_DEFINITION_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an attribute definition
|
||||
* @return void
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$attributes_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
if($this->attribute->delete_definition_list($attributes_to_delete))
|
||||
{
|
||||
$message = lang('Attributes.definition_successful_deleted') . ' ' . count($attributes_to_delete) . ' ' . lang('Attributes.definition_one_or_multiple');
|
||||
echo json_encode(['success' => true, 'message' => $message]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(['success' => false, 'message' => lang('Attributes.definition_cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
58
app/Controllers/BaseController.php
Normal file
58
app/Controllers/BaseController.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\Controller;
|
||||
use CodeIgniter\HTTP\CLIRequest;
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Class BaseController
|
||||
*
|
||||
* BaseController provides a convenient place for loading components
|
||||
* and performing functions that are needed by all your controllers.
|
||||
* Extend this class in any new controllers:
|
||||
* class Home extends BaseController
|
||||
*
|
||||
* For security be sure to declare any new methods as protected or private.
|
||||
*/
|
||||
abstract class BaseController extends Controller
|
||||
{
|
||||
/**
|
||||
* Instance of the main Request object.
|
||||
*
|
||||
* @var CLIRequest|IncomingRequest
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* An array of helpers to be loaded automatically upon
|
||||
* class instantiation. These helpers will be available
|
||||
* to all other controllers that extend BaseController.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $helpers = [];
|
||||
|
||||
/**
|
||||
* Be sure to declare properties for any property fetch you initialized.
|
||||
* The creation of dynamic property is deprecated in PHP 8.2.
|
||||
*/
|
||||
// protected $session;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
// Do Not Edit This Line
|
||||
parent::initController($request, $response, $logger);
|
||||
|
||||
// Preload any models, libraries, etc, here.
|
||||
|
||||
// E.g.: $this->session = \Config\Services::session();
|
||||
}
|
||||
}
|
||||
324
app/Controllers/Cashups.php
Normal file
324
app/Controllers/Cashups.php
Normal file
@@ -0,0 +1,324 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Cashup;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Reports\Summary_payments;
|
||||
use Config\OSPOS;
|
||||
|
||||
class Cashups extends Secure_Controller
|
||||
{
|
||||
private Cashup $cashup;
|
||||
private Expense $expense;
|
||||
private Summary_payments $summary_payments;
|
||||
private array $config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('cashups');
|
||||
|
||||
$this->cashup = model(Cashup::class);
|
||||
$this->expense = model(Expense::class);
|
||||
$this->summary_payments = model(Summary_payments::class);
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['table_headers'] = get_cashups_manage_table_headers();
|
||||
|
||||
// filters that will be loaded in the multiselect dropdown
|
||||
$data['filters'] = ['is_deleted' => lang('Cashups.is_deleted')];
|
||||
|
||||
echo view('cashups/manage', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$filters = [
|
||||
'start_date' => $this->request->getGet('start_date', FILTER_SANITIZE_FULL_SPECIAL_CHARS), //TODO: Is this the best way to filter dates
|
||||
'end_date' => $this->request->getGet('end_date', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'is_deleted' => false
|
||||
];
|
||||
|
||||
// check if any filter is set in the multiselect dropdown
|
||||
$request_filters = array_fill_keys($this->request->getGet('filters', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? [], true);
|
||||
$filters = array_merge($filters, $request_filters);
|
||||
$cash_ups = $this->cashup->search($search, $filters, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->cashup->get_found_rows($search, $filters);
|
||||
$data_rows = [];
|
||||
foreach($cash_ups->getResult() as $cash_up)
|
||||
{
|
||||
$data_rows[] = get_cash_up_data_row($cash_up);
|
||||
}
|
||||
|
||||
echo json_encode(['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $cashup_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $cashup_id = NEW_ENTRY): void
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$data['employees'] = [];
|
||||
foreach($this->employee->get_all()->getResult() as $employee)
|
||||
{
|
||||
foreach(get_object_vars($employee) as $property => $value)
|
||||
{
|
||||
$employee->$property = $value;
|
||||
}
|
||||
|
||||
$data['employees'][$employee->person_id] = $employee->first_name . ' ' . $employee->last_name;
|
||||
}
|
||||
|
||||
$cash_ups_info = $this->cashup->get_info($cashup_id);
|
||||
|
||||
foreach(get_object_vars($cash_ups_info) as $property => $value)
|
||||
{
|
||||
$cash_ups_info->$property = $value;
|
||||
}
|
||||
|
||||
// open cashup
|
||||
if($cash_ups_info->cashup_id == NEW_ENTRY)
|
||||
{
|
||||
$cash_ups_info->open_date = date('Y-m-d H:i:s');
|
||||
$cash_ups_info->close_date = $cash_ups_info->open_date;
|
||||
$cash_ups_info->open_employee_id = $this->employee->get_logged_in_employee_info()->person_id;
|
||||
$cash_ups_info->close_employee_id = $this->employee->get_logged_in_employee_info()->person_id;
|
||||
}
|
||||
// if all the amounts are null or 0 that means it's a close cashup
|
||||
elseif(floatval($cash_ups_info->closed_amount_cash) == 0
|
||||
&& floatval($cash_ups_info->closed_amount_due) == 0
|
||||
&& floatval($cash_ups_info->closed_amount_card) == 0
|
||||
&& floatval($cash_ups_info->closed_amount_check) == 0)
|
||||
{
|
||||
// set the close date and time to the actual as this is a close session
|
||||
$cash_ups_info->close_date = date('Y-m-d H:i:s');
|
||||
|
||||
// the closed amount starts with the open amount -/+ any trasferred amount
|
||||
$cash_ups_info->closed_amount_cash = $cash_ups_info->open_amount_cash + $cash_ups_info->transfer_amount_cash;
|
||||
|
||||
// if it's date mode only and not date & time truncate the open and end date to date only
|
||||
if(empty($this->config['date_or_time_format']))
|
||||
{
|
||||
if($cash_ups_info->open_date != null)
|
||||
{
|
||||
$start_date = substr($cash_ups_info->open_date, 0, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
$start_date = null;
|
||||
}
|
||||
if($cash_ups_info->close_date != null)
|
||||
{
|
||||
$end_date = substr($cash_ups_info->close_date, 0, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
$end_date = null;
|
||||
}
|
||||
// search for all the payments given the time range
|
||||
$inputs = [
|
||||
'start_date' => $start_date,
|
||||
'end_date' => $end_date,
|
||||
'sale_type' => 'complete',
|
||||
'location_id' => 'all'
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
// search for all the payments given the time range
|
||||
$inputs = [
|
||||
'start_date' => $cash_ups_info->open_date,
|
||||
'end_date' => $cash_ups_info->close_date,
|
||||
'sale_type' => 'complete',
|
||||
'location_id' => 'all'
|
||||
];
|
||||
}
|
||||
|
||||
// get all the transactions payment summaries
|
||||
$reports_data = $this->summary_payments->getData($inputs);
|
||||
|
||||
foreach($reports_data as $row)
|
||||
{
|
||||
if($row['trans_group'] == lang('Reports.trans_payments'))
|
||||
{
|
||||
if($row['trans_type'] == lang('Sales.cash'))
|
||||
{
|
||||
$cash_ups_info->closed_amount_cash += $row['trans_amount'];
|
||||
}
|
||||
elseif($row['trans_type'] == lang('Sales.due'))
|
||||
{
|
||||
$cash_ups_info->closed_amount_due += $row['trans_amount'];
|
||||
}
|
||||
elseif($row['trans_type'] == lang('Sales.debit') ||
|
||||
$row['trans_type'] == lang('Sales.credit'))
|
||||
{
|
||||
$cash_ups_info->closed_amount_card += $row['trans_amount'];
|
||||
}
|
||||
elseif($row['trans_type'] == lang('Sales.check'))
|
||||
{
|
||||
$cash_ups_info->closed_amount_check += $row['trans_amount'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// lookup expenses paid in cash
|
||||
$filters = [
|
||||
'only_cash' => true,
|
||||
'only_due' => false,
|
||||
'only_check' => false,
|
||||
'only_credit' => false,
|
||||
'only_debit' => false,
|
||||
'is_deleted' => false
|
||||
];
|
||||
|
||||
$payments = $this->expense->get_payments_summary('', array_merge($inputs, $filters));
|
||||
|
||||
foreach($payments as $row)
|
||||
{
|
||||
$cash_ups_info->closed_amount_cash -= $row['amount'];
|
||||
}
|
||||
|
||||
$cash_ups_info->closed_amount_total = $this->_calculate_total($cash_ups_info->open_amount_cash, $cash_ups_info->transfer_amount_cash, $cash_ups_info->closed_amount_cash, $cash_ups_info->closed_amount_due, $cash_ups_info->closed_amount_card, $cash_ups_info->closed_amount_check);
|
||||
}
|
||||
|
||||
$data['cash_ups_info'] = $cash_ups_info;
|
||||
|
||||
echo view("cashups/form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $row_id
|
||||
* @return void
|
||||
*/
|
||||
public function getRow(int $row_id): void
|
||||
{
|
||||
$cash_ups_info = $this->cashup->get_info($row_id);
|
||||
$data_row = get_cash_up_data_row($cash_ups_info);
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $cashup_id
|
||||
* @return void
|
||||
*/
|
||||
public function postSave(int $cashup_id = NEW_ENTRY): void
|
||||
{
|
||||
$open_date = $this->request->getPost('open_date');
|
||||
$open_date_formatter = date_create_from_format($this->config['dateformat'] . ' ' . $this->config['timeformat'], $open_date);
|
||||
|
||||
$close_date = $this->request->getPost('close_date');
|
||||
$close_date_formatter = date_create_from_format($this->config['dateformat'] . ' ' . $this->config['timeformat'], $close_date);
|
||||
|
||||
$open_amount_cash = prepare_decimal($this->request->getPost('open_amount_cash'));
|
||||
$transfer_amount_cash = prepare_decimal($this->request->getPost('transfer_amount_cash'));
|
||||
$closed_amount_cash = prepare_decimal($this->request->getPost('closed_amount_cash'));
|
||||
$closed_amount_due = prepare_decimal($this->request->getPost('closed_amount_due'));
|
||||
$closed_amount_card = prepare_decimal($this->request->getPost('closed_amount_card'));
|
||||
$closed_amount_check = prepare_decimal($this->request->getPost('closed_amount_check'));
|
||||
$closed_amount_total = prepare_decimal($this->request->getPost('closed_amount_total'));
|
||||
|
||||
$cash_up_data = [
|
||||
'open_date' => $open_date_formatter->format('Y-m-d H:i:s'),
|
||||
'close_date' => $close_date_formatter->format('Y-m-d H:i:s'),
|
||||
'open_amount_cash' => parse_decimals(filter_var($open_amount_cash, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'transfer_amount_cash' => parse_decimals(filter_var($transfer_amount_cash, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'closed_amount_cash' => parse_decimals(filter_var($closed_amount_cash, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'closed_amount_due' => parse_decimals(filter_var($closed_amount_due, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'closed_amount_card' => parse_decimals(filter_var($closed_amount_card, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'closed_amount_check' => parse_decimals(filter_var($closed_amount_check, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'closed_amount_total' => parse_decimals(filter_var($closed_amount_total, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)),
|
||||
'note' => $this->request->getPost('note') != null,
|
||||
'description' => $this->request->getPost('description', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'open_employee_id' => $this->request->getPost('open_employee_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'close_employee_id' => $this->request->getPost('close_employee_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'deleted' => $this->request->getPost('deleted') != null
|
||||
];
|
||||
|
||||
if($this->cashup->save_value($cash_up_data, $cashup_id))
|
||||
{
|
||||
//New cashup_id
|
||||
if($cashup_id == NEW_ENTRY)
|
||||
{
|
||||
echo json_encode(['success' => true, 'message' => lang('Cashups.successful_adding'), 'id' => $cash_up_data['cashup_id']]);
|
||||
}
|
||||
else // Existing Cashup
|
||||
{
|
||||
echo json_encode(['success' => true, 'message' => lang('Cashups.successful_updating'), 'id' => $cashup_id]);
|
||||
}
|
||||
}
|
||||
else//failure
|
||||
{
|
||||
echo json_encode(['success' => false, 'message' => lang('Cashups.error_adding_updating'), 'id' => NEW_ENTRY]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$cash_ups_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
if($this->cashup->delete_list($cash_ups_to_delete))
|
||||
{
|
||||
echo json_encode(['success' => true, 'message' => lang('Cashups.successful_deleted') . ' ' . count($cash_ups_to_delete) . ' ' . lang('Cashups.one_or_multiple'), 'ids' => $cash_ups_to_delete]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode(['success' => false, 'message' => lang('Cashups.cannot_be_deleted'), 'ids' => $cash_ups_to_delete]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the total for cashups. Used in app\Views\cashups\form.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function ajax_cashup_total(): void
|
||||
{
|
||||
$raw_open_amount_cash = $this->request->getPost('open_amount_cash');
|
||||
$raw_transfer_amount_cash = $this->request->getPost('transfer_amount_cash');
|
||||
$raw_closed_amount_cash = $this->request->getPost('closed_amount_cash');
|
||||
$raw_closed_amount_due = $this->request->getPost('closed_amount_due');
|
||||
$raw_closed_amount_card = $this->request->getPost('closed_amount_card');
|
||||
$raw_closed_amount_check = $this->request->getPost('closed_amount_check');
|
||||
|
||||
$open_amount_cash = parse_decimals(filter_var(prepare_decimal($raw_open_amount_cash), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$transfer_amount_cash = parse_decimals(filter_var(prepare_decimal($raw_transfer_amount_cash), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$closed_amount_cash = parse_decimals(filter_var(prepare_decimal($raw_closed_amount_cash), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$closed_amount_due = parse_decimals(filter_var(prepare_decimal($raw_closed_amount_due), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$closed_amount_card = parse_decimals(filter_var(prepare_decimal($raw_closed_amount_card), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
$closed_amount_check = parse_decimals(filter_var(prepare_decimal($raw_closed_amount_check), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
|
||||
$total = $this->_calculate_total($open_amount_cash, $transfer_amount_cash, $closed_amount_due, $closed_amount_cash, $closed_amount_card, $closed_amount_check); //TODO: hungarian notation
|
||||
|
||||
echo json_encode(['total' => to_currency_no_money($total)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate total
|
||||
*/
|
||||
private function _calculate_total(float $open_amount_cash, float $transfer_amount_cash, float $closed_amount_due, float $closed_amount_cash, float $closed_amount_card, $closed_amount_check): float //TODO: need to get rid of hungarian notation here. Also, the signature is pretty long. Perhaps they need to go into an object or array?
|
||||
{
|
||||
return ($closed_amount_cash - $open_amount_cash - $transfer_amount_cash + $closed_amount_due + $closed_amount_card + $closed_amount_check);
|
||||
}
|
||||
}
|
||||
1060
app/Controllers/Config.php
Normal file
1060
app/Controllers/Config.php
Normal file
File diff suppressed because it is too large
Load Diff
540
app/Controllers/Customers.php
Normal file
540
app/Controllers/Customers.php
Normal file
@@ -0,0 +1,540 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Libraries\Mailchimp_lib;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\Customer_rewards;
|
||||
use App\Models\Tax_code;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
use stdClass;
|
||||
|
||||
class Customers extends Persons
|
||||
{
|
||||
private string $_list_id;
|
||||
private Mailchimp_lib $mailchimp_lib;
|
||||
private Customer_rewards $customer_rewards;
|
||||
private Customer $customer;
|
||||
private Tax_code $tax_code;
|
||||
private array $config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('customers');
|
||||
$this->mailchimp_lib = new Mailchimp_lib();
|
||||
$this->customer_rewards = model(Customer_rewards::class);
|
||||
$this->customer = model(Customer::class);
|
||||
$this->tax_code = model(Tax_code::class);
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
|
||||
$encrypter = Services::encrypter();
|
||||
|
||||
if(!empty($this->config['mailchimp_list_id']))
|
||||
{
|
||||
$this->_list_id = $encrypter->decrypt($this->config['mailchimp_list_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_list_id = '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['table_headers'] = get_customer_manage_table_headers();
|
||||
|
||||
echo view('people/manage', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets one row for a customer manage table. This is called using AJAX to update one row.
|
||||
*/
|
||||
public function getRow(int $row_id): void
|
||||
{
|
||||
$person = $this->customer->get_info($row_id);
|
||||
|
||||
// retrieve the total amount the customer spent so far together with min, max and average values
|
||||
$stats = $this->customer->get_stats($person->person_id); //TODO: This and the next 11 lines are duplicated in search(). Extract a method.
|
||||
|
||||
if(empty($stats))
|
||||
{
|
||||
//create object with empty properties.
|
||||
$stats = new stdClass();
|
||||
$stats->total = 0;
|
||||
$stats->min = 0;
|
||||
$stats->max = 0;
|
||||
$stats->average = 0;
|
||||
$stats->avg_discount = 0;
|
||||
$stats->quantity = 0;
|
||||
}
|
||||
|
||||
$data_row = get_customer_data_row($person, $stats);
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns customer table data rows. This will be called with AJAX.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = Services::htmlPurifier()->purify($this->request->getGet('search'));
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$customers = $this->customer->search($search, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->customer->get_found_rows($search);
|
||||
|
||||
$data_rows = [];
|
||||
|
||||
foreach($customers->getResult() as $person)
|
||||
{
|
||||
// retrieve the total amount the customer spent so far together with min, max and average values
|
||||
$stats = $this->customer->get_stats($person->person_id); //TODO: duplicated... see above
|
||||
if(empty($stats))
|
||||
{
|
||||
//create object with empty properties.
|
||||
$stats = new stdClass();
|
||||
$stats->total = 0;
|
||||
$stats->min = 0;
|
||||
$stats->max = 0;
|
||||
$stats->average = 0;
|
||||
$stats->avg_discount = 0;
|
||||
$stats->quantity = 0;
|
||||
}
|
||||
|
||||
$data_rows[] = get_customer_data_row($person, $stats);
|
||||
}
|
||||
|
||||
echo json_encode (['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives search suggestions based on what is being searched for
|
||||
*/
|
||||
public function getSuggest(): void
|
||||
{
|
||||
$suggestions = $this->customer->get_search_suggestions($this->request->getGet('term'), 25,true);
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function suggest_search(): void
|
||||
{
|
||||
$suggestions = $this->customer->get_search_suggestions($this->request->getPost('term'), 25, false);
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the customer edit form
|
||||
*/
|
||||
public function getView(int $customer_id = NEW_ENTRY): void
|
||||
{
|
||||
// Set default values
|
||||
if($customer_id == null) $customer_id = NEW_ENTRY;
|
||||
|
||||
$info = $this->customer->get_info($customer_id);
|
||||
foreach(get_object_vars($info) as $property => $value)
|
||||
{
|
||||
$info->$property = $value;
|
||||
}
|
||||
$data['person_info'] = $info;
|
||||
|
||||
if(empty($info->person_id) || empty($info->date) || empty($info->employee_id))
|
||||
{
|
||||
$data['person_info']->date = date('Y-m-d H:i:s');
|
||||
$data['person_info']->employee_id = $this->employee->get_logged_in_employee_info()->person_id;
|
||||
}
|
||||
|
||||
$employee_info = $this->employee->get_info($info->employee_id);
|
||||
$data['employee'] = $employee_info->first_name . ' ' . $employee_info->last_name;
|
||||
|
||||
$tax_code_info = $this->tax_code->get_info($info->sales_tax_code_id);
|
||||
|
||||
if($tax_code_info->tax_code != null)
|
||||
{
|
||||
$data['sales_tax_code_label'] = $tax_code_info->tax_code . ' ' . $tax_code_info->tax_code_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['sales_tax_code_label'] = '';
|
||||
}
|
||||
|
||||
$packages = ['' => lang('Items.none')];
|
||||
foreach($this->customer_rewards->get_all()->getResultArray() as $row)
|
||||
{
|
||||
$packages[$row['package_id']] = $row['package_name'];
|
||||
}
|
||||
$data['packages'] = $packages;
|
||||
$data['selected_package'] = $info->package_id;
|
||||
|
||||
if($this->config['use_destination_based_tax']) //TODO: This can be shortened for ternary notation
|
||||
{
|
||||
$data['use_destination_based_tax'] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['use_destination_based_tax'] = false;
|
||||
}
|
||||
|
||||
// retrieve the total amount the customer spent so far together with min, max and average values
|
||||
$stats = $this->customer->get_stats($customer_id);
|
||||
if(!empty($stats))
|
||||
{
|
||||
foreach(get_object_vars($stats) as $property => $value)
|
||||
{
|
||||
$info->$property = $value;
|
||||
}
|
||||
$data['stats'] = $stats;
|
||||
}
|
||||
|
||||
// retrieve the info from Mailchimp only if there is an email address assigned
|
||||
if(!empty($info->email))
|
||||
{
|
||||
// collect mailchimp customer info
|
||||
if(($mailchimp_info = $this->mailchimp_lib->getMemberInfo($this->_list_id, $info->email)) !== false)
|
||||
{
|
||||
$data['mailchimp_info'] = $mailchimp_info;
|
||||
|
||||
// collect customer mailchimp emails activities (stats)
|
||||
if(($activities = $this->mailchimp_lib->getMemberActivity($this->_list_id, $info->email)) !== false)
|
||||
{
|
||||
if(array_key_exists('activity', $activities))
|
||||
{
|
||||
$open = 0;
|
||||
$unopen = 0;
|
||||
$click = 0;
|
||||
$total = 0;
|
||||
$lastopen = '';
|
||||
|
||||
foreach($activities['activity'] as $activity)
|
||||
{
|
||||
if($activity['action'] == 'sent')
|
||||
{
|
||||
++$unopen;
|
||||
}
|
||||
elseif($activity['action'] == 'open')
|
||||
{
|
||||
if(empty($lastopen))
|
||||
{
|
||||
$lastopen = substr($activity['timestamp'], 0, 10);
|
||||
}
|
||||
++$open;
|
||||
}
|
||||
elseif($activity['action'] == 'click')
|
||||
{
|
||||
if(empty($lastopen))
|
||||
{
|
||||
$lastopen = substr($activity['timestamp'], 0, 10);
|
||||
}
|
||||
++$click;
|
||||
}
|
||||
|
||||
++$total;
|
||||
}
|
||||
|
||||
$data['mailchimp_activity']['total'] = $total;
|
||||
$data['mailchimp_activity']['open'] = $open;
|
||||
$data['mailchimp_activity']['unopen'] = $unopen;
|
||||
$data['mailchimp_activity']['click'] = $click;
|
||||
$data['mailchimp_activity']['lastopen'] = $lastopen;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo view("customers/form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts/updates a customer
|
||||
*/
|
||||
public function postSave(int $customer_id = NEW_ENTRY): void
|
||||
{
|
||||
$first_name = $this->request->getPost('first_name');
|
||||
$last_name = $this->request->getPost('last_name');
|
||||
$email = strtolower($this->request->getPost('email', FILTER_SANITIZE_EMAIL));
|
||||
|
||||
// format first and last name properly
|
||||
$first_name = $this->nameize($first_name);
|
||||
$last_name = $this->nameize($last_name);
|
||||
|
||||
$person_data = [
|
||||
'first_name' => $first_name,
|
||||
'last_name' => $last_name,
|
||||
'gender' => $this->request->getPost('gender', FILTER_SANITIZE_NUMBER_INT),
|
||||
'email' => $email,
|
||||
'phone_number' => $this->request->getPost('phone_number'),
|
||||
'address_1' => $this->request->getPost('address_1'),
|
||||
'address_2' => $this->request->getPost('address_2'),
|
||||
'city' => $this->request->getPost('city'),
|
||||
'state' => $this->request->getPost('state'),
|
||||
'zip' => $this->request->getPost('zip'),
|
||||
'country' => $this->request->getPost('country'),
|
||||
'comments' => $this->request->getPost('comments')
|
||||
];
|
||||
|
||||
$date_formatter = date_create_from_format($this->config['dateformat'] . ' ' . $this->config['timeformat'], $this->request->getPost('date'));
|
||||
|
||||
$discount = prepare_decimal($this->request->getPost('discount'));
|
||||
|
||||
$customer_data = [
|
||||
'consent' => $this->request->getPost('consent') != null,
|
||||
'account_number' => $this->request->getPost('account_number') == '' ? null : $this->request->getPost('account_number'),
|
||||
'tax_id' => $this->request->getPost('tax_id'),
|
||||
'company_name' => $this->request->getPost('company_name') == '' ? null : $this->request->getPost('company_name'),
|
||||
'discount' => $this->request->getPost('discount') == '' ? 0.00 : filter_var($discount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'discount_type' => $this->request->getPost('discount_type') == null ? PERCENT : $this->request->getPost('discount_type', FILTER_SANITIZE_NUMBER_INT),
|
||||
'package_id' => $this->request->getPost('package_id') == '' ? null : $this->request->getPost('package_id'),
|
||||
'taxable' => $this->request->getPost('taxable') != null,
|
||||
'date' => $date_formatter->format('Y-m-d H:i:s'),
|
||||
'employee_id' => $this->request->getPost('employee_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'sales_tax_code_id' => $this->request->getPost('sales_tax_code_id') == '' ? null : $this->request->getPost('sales_tax_code_id', FILTER_SANITIZE_NUMBER_INT)
|
||||
];
|
||||
|
||||
if($this->customer->save_customer($person_data, $customer_data, $customer_id))
|
||||
{
|
||||
// save customer to Mailchimp selected list //TODO: addOrUpdateMember should be refactored... potentially pass an array or object instead of 6 parameters.
|
||||
$mailchimp_status = $this->request->getPost('mailchimp_status');
|
||||
$this->mailchimp_lib->addOrUpdateMember(
|
||||
$this->_list_id,
|
||||
$email,
|
||||
$first_name,
|
||||
$last_name,
|
||||
$mailchimp_status == null ? "" : $mailchimp_status,
|
||||
['vip' => $this->request->getPost('mailchimp_vip') != null]
|
||||
);
|
||||
|
||||
// New customer
|
||||
if($customer_id == NEW_ENTRY)
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Customers.successful_adding') . ' ' . $first_name . ' ' . $last_name,
|
||||
'id' => $customer_data['person_id']
|
||||
]);
|
||||
}
|
||||
else // Existing customer
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Customers.successful_updating') . ' ' . $first_name . ' ' . $last_name,
|
||||
'id' => $customer_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
else // Failure
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Customers.error_adding_updating') . ' ' . $first_name . ' ' . $last_name,
|
||||
'id' => NEW_ENTRY
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if an email address already exists. Used in app/Views/customers/form.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postCheckEmail(): void
|
||||
{
|
||||
$email = strtolower($this->request->getPost('email', FILTER_SANITIZE_EMAIL));
|
||||
$person_id = $this->request->getPost('person_id', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
$exists = $this->customer->check_email_exists($email, $person_id);
|
||||
|
||||
echo !$exists ? 'true' : 'false';
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if an account number already exists. Used in app/Views/customers/form.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postCheckAccountNumber(): void
|
||||
{
|
||||
$exists = $this->customer->check_account_number_exists($this->request->getPost('account_number'), $this->request->getPost('person_id', FILTER_SANITIZE_NUMBER_INT));
|
||||
|
||||
echo !$exists ? 'true' : 'false';
|
||||
}
|
||||
|
||||
/**
|
||||
* This deletes customers from the customers table
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$customers_to_delete = $this->request->getPost('ids');
|
||||
$customers_info = $this->customer->get_multiple_info($customers_to_delete);
|
||||
|
||||
$count = 0;
|
||||
|
||||
foreach($customers_info->getResult() as $info)
|
||||
{
|
||||
if($this->customer->delete($info->person_id))
|
||||
{
|
||||
// remove customer from Mailchimp selected list
|
||||
$this->mailchimp_lib->removeMember($this->_list_id, $info->email);
|
||||
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
if($count == count($customers_to_delete))
|
||||
{
|
||||
echo json_encode (['success' => true,
|
||||
'message' => lang('Customers.successful_deleted') . ' ' . $count . ' ' . lang('Customers.one_or_multiple')]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Customers.cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Customers import from csv spreadsheet
|
||||
*
|
||||
* @return DownloadResponse The template for Customer CSV imports is returned and download forced.
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getCsv(): DownloadResponse
|
||||
{
|
||||
$name = 'import_customers.csv';
|
||||
$data = file_get_contents(WRITEPATH . "uploads/$name");
|
||||
return $this->response->download($name, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the customer CSV import modal. Used in app/Views/people/manage.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getCsvImport(): void
|
||||
{
|
||||
echo view('customers/form_csv_import');
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports a CSV file containing customers. Used in app/Views/customers/form_csv_import.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postImportCsvFile(): void
|
||||
{
|
||||
if($_FILES['file_path']['error'] != UPLOAD_ERR_OK)
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Customers.csv_import_failed')]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(($handle = fopen($_FILES['file_path']['tmp_name'], 'r')) !== false)
|
||||
{
|
||||
// Skip the first row as it's the table description
|
||||
fgetcsv($handle);
|
||||
$i = 1;
|
||||
|
||||
$failCodes = [];
|
||||
|
||||
while(($data = fgetcsv($handle)) !== false)
|
||||
{
|
||||
$consent = $data[3] == '' ? 0 : 1;
|
||||
|
||||
if(sizeof($data) >= 16 && $consent)
|
||||
{
|
||||
$email = strtolower($data[4]);
|
||||
$person_data = [
|
||||
'first_name' => $data[0],
|
||||
'last_name' => $data[1],
|
||||
'gender' => $data[2],
|
||||
'email' => $email,
|
||||
'phone_number' => $data[5],
|
||||
'address_1' => $data[6],
|
||||
'address_2' => $data[7],
|
||||
'city' => $data[8],
|
||||
'state' => $data[9],
|
||||
'zip' => $data[10],
|
||||
'country' => $data[11],
|
||||
'comments' => $data[12]
|
||||
];
|
||||
|
||||
$customer_data = [
|
||||
'consent' => $consent,
|
||||
'company_name' => $data[13],
|
||||
'discount' => $data[15],
|
||||
'discount_type' => $data[16],
|
||||
'taxable' => $data[17] == '' ? 0 : 1,
|
||||
'date' => date('Y-m-d H:i:s'),
|
||||
'employee_id' => $this->employee->get_logged_in_employee_info()->person_id
|
||||
];
|
||||
$account_number = $data[14];
|
||||
|
||||
// don't duplicate people with same email
|
||||
$invalidated = $this->customer->check_email_exists($email);
|
||||
|
||||
if($account_number != '')
|
||||
{
|
||||
$customer_data['account_number'] = $account_number;
|
||||
$invalidated &= $this->customer->check_account_number_exists($account_number);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$invalidated = true;
|
||||
}
|
||||
|
||||
if($invalidated)
|
||||
{
|
||||
$failCodes[] = $i;
|
||||
log_message('error',"Row $i was not imported: Either email or account number already exist or data was invalid.");
|
||||
}
|
||||
elseif($this->customer->save_customer($person_data, $customer_data))
|
||||
{
|
||||
// save customer to Mailchimp selected list
|
||||
$this->mailchimp_lib->addOrUpdateMember($this->_list_id, $person_data['email'], $person_data['first_name'], '', $person_data['last_name']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$failCodes[] = $i;
|
||||
}
|
||||
|
||||
++$i;
|
||||
}
|
||||
|
||||
if(count($failCodes) > 0)
|
||||
{
|
||||
$message = lang('Customers.csv_import_partially_failed', [count($failCodes), implode(', ', $failCodes)]);
|
||||
|
||||
echo json_encode (['success' => false, 'message' => $message]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => true, 'message' => lang('Customers.csv_import_success')]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Customers.csv_import_nodata_wrongformat')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
231
app/Controllers/Employees.php
Normal file
231
app/Controllers/Employees.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Module;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @property module module
|
||||
*
|
||||
*/
|
||||
class Employees extends Persons
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('employees');
|
||||
|
||||
$this->module = model('Module');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns employee table data rows. This will be called with AJAX.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$employees = $this->employee->search($search, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->employee->get_found_rows($search);
|
||||
|
||||
$data_rows = [];
|
||||
foreach($employees->getResult() as $person)
|
||||
{
|
||||
$data_rows[] = get_person_data_row($person);
|
||||
}
|
||||
|
||||
echo json_encode (['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX called function gives search suggestions based on what is being searched for.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSuggest(): void
|
||||
{
|
||||
$suggestions = $this->employee->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), 25, true);
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function suggest_search(): void
|
||||
{
|
||||
$suggestions = $this->employee->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the employee edit form
|
||||
*/
|
||||
public function getView(int $employee_id = NEW_ENTRY): void
|
||||
{
|
||||
$person_info = $this->employee->get_info($employee_id);
|
||||
foreach(get_object_vars($person_info) as $property => $value)
|
||||
{
|
||||
$person_info->$property = $value;
|
||||
}
|
||||
$data['person_info'] = $person_info;
|
||||
$data['employee_id'] = $employee_id;
|
||||
|
||||
$modules = [];
|
||||
foreach($this->module->get_all_modules()->getResult() as $module)
|
||||
{
|
||||
$module->grant = $this->employee->has_grant($module->module_id, $person_info->person_id);
|
||||
$module->menu_group = $this->employee->get_menu_group($module->module_id, $person_info->person_id);
|
||||
|
||||
$modules[] = $module;
|
||||
}
|
||||
$data['all_modules'] = $modules;
|
||||
|
||||
$permissions = [];
|
||||
foreach($this->module->get_all_subpermissions()->getResult() as $permission) //TODO: subpermissions does not follow naming standards.
|
||||
{
|
||||
$permission->permission_id = str_replace(' ', '_', $permission->permission_id);
|
||||
$permission->grant = $this->employee->has_grant($permission->permission_id, $person_info->person_id);
|
||||
|
||||
$permissions[] = $permission;
|
||||
}
|
||||
$data['all_subpermissions'] = $permissions;
|
||||
|
||||
echo view('employees/form', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts/updates an employee
|
||||
*/
|
||||
public function postSave(int $employee_id = NEW_ENTRY): void
|
||||
{
|
||||
$first_name = $this->request->getPost('first_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS); //TODO: duplicated code
|
||||
$last_name = $this->request->getPost('last_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$email = strtolower($this->request->getPost('email', FILTER_SANITIZE_EMAIL));
|
||||
|
||||
// format first and last name properly
|
||||
$first_name = $this->nameize($first_name);
|
||||
$last_name = $this->nameize($last_name);
|
||||
|
||||
$person_data = [
|
||||
'first_name' => $first_name,
|
||||
'last_name' => $last_name,
|
||||
'gender' => $this->request->getPost('gender', FILTER_SANITIZE_NUMBER_INT),
|
||||
'email' => $email,
|
||||
'phone_number' => $this->request->getPost('phone_number', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'address_1' => $this->request->getPost('address_1', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'address_2' => $this->request->getPost('address_2', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'city' => $this->request->getPost('city', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'state' => $this->request->getPost('state', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'zip' => $this->request->getPost('zip', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'country' => $this->request->getPost('country', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'comments' => $this->request->getPost('comments', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
|
||||
];
|
||||
|
||||
$grants_array = [];
|
||||
foreach($this->module->get_all_permissions()->getResult() as $permission)
|
||||
{
|
||||
$grants = [];
|
||||
$grant = $this->request->getPost('grant_'.$permission->permission_id) != null ? $this->request->getPost('grant_' . $permission->permission_id, FILTER_SANITIZE_FULL_SPECIAL_CHARS) : '';
|
||||
|
||||
if($grant == $permission->permission_id)
|
||||
{
|
||||
$grants['permission_id'] = $permission->permission_id;
|
||||
$grants['menu_group'] = $this->request->getPost('menu_group_'.$permission->permission_id) != null ? $this->request->getPost('menu_group_' . $permission->permission_id, FILTER_SANITIZE_FULL_SPECIAL_CHARS) : '--';
|
||||
$grants_array[] = $grants;
|
||||
}
|
||||
}
|
||||
|
||||
//Password has been changed OR first time password set
|
||||
if(!empty($this->request->getPost('password')) && ENVIRONMENT != 'testing')
|
||||
{
|
||||
$exploded = explode(":", $this->request->getPost('language', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
$employee_data = [
|
||||
'username' => $this->request->getPost('username', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'password' => password_hash($this->request->getPost('password'), PASSWORD_DEFAULT),
|
||||
'hash_version' => 2,
|
||||
'language_code' => $exploded[0],
|
||||
'language' => $exploded[1]
|
||||
];
|
||||
}
|
||||
else //Password not changed
|
||||
{
|
||||
$exploded = explode(":", $this->request->getPost('language', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
$employee_data = [
|
||||
'username' => $this->request->getPost('username', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'language_code' => $exploded[0],
|
||||
'language' => $exploded[1]
|
||||
];
|
||||
}
|
||||
|
||||
if($this->employee->save_employee($person_data, $employee_data, $grants_array, $employee_id))
|
||||
{
|
||||
// New employee
|
||||
if($employee_id == NEW_ENTRY)
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Employees.successful_adding') . ' ' . $first_name . ' ' . $last_name,
|
||||
'id' => $employee_data['person_id']
|
||||
]);
|
||||
}
|
||||
else // Existing employee
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Employees.successful_updating') . ' ' . $first_name . ' ' . $last_name,
|
||||
'id' => $employee_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
else // Failure
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Employees.error_adding_updating') . ' ' . $first_name . ' ' . $last_name,
|
||||
'id' => NEW_ENTRY
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This deletes employees from the employees table
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$employees_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
if($this->employee->delete_list($employees_to_delete)) //TODO: this is passing a string, but delete_list expects an array
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Employees.successful_deleted') . ' ' . count($employees_to_delete) . ' ' . lang('Employees.one_or_multiple')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Employees.cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks an employee username against the database. Used in app\Views\employees\form.php
|
||||
*
|
||||
* @param $employee_id
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getCheckUsername($employee_id): void
|
||||
{
|
||||
$exists = $this->employee->username_exists($employee_id, $this->request->getGet('username'));
|
||||
echo !$exists ? 'true' : 'false';
|
||||
}
|
||||
}
|
||||
223
app/Controllers/Expenses.php
Normal file
223
app/Controllers/Expenses.php
Normal file
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Expense;
|
||||
use App\Models\Expense_category;
|
||||
use Config\OSPOS;
|
||||
|
||||
class Expenses extends Secure_Controller
|
||||
{
|
||||
private Expense $expense;
|
||||
private Expense_category $expense_category;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('expenses');
|
||||
|
||||
$this->expense = model(Expense::class);
|
||||
$this->expense_category = model(Expense_category::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['table_headers'] = get_expenses_manage_table_headers();
|
||||
|
||||
// filters that will be loaded in the multiselect dropdown
|
||||
$data['filters'] = [
|
||||
'only_cash' => lang('Expenses.cash_filter'),
|
||||
'only_due' => lang('Expenses.due_filter'),
|
||||
'only_check' => lang('Expenses.check_filter'),
|
||||
'only_credit' => lang('Expenses.credit_filter'),
|
||||
'only_debit' => lang('Expenses.debit_filter'),
|
||||
'is_deleted' => lang('Expenses.is_deleted')
|
||||
];
|
||||
|
||||
echo view('expenses/manage', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$filters = [
|
||||
'start_date' => $this->request->getGet('start_date', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'end_date' => $this->request->getGet('end_date', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'only_cash' => false,
|
||||
'only_due' => false,
|
||||
'only_check' => false,
|
||||
'only_credit' => false,
|
||||
'only_debit' => false,
|
||||
'is_deleted' => false
|
||||
];
|
||||
|
||||
// check if any filter is set in the multiselect dropdown
|
||||
$request_filters = array_fill_keys($this->request->getGet('filters', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? [], true);
|
||||
$filters = array_merge($filters, $request_filters);
|
||||
$expenses = $this->expense->search($search, $filters, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->expense->get_found_rows($search, $filters);
|
||||
$payments = $this->expense->get_payments_summary($search, $filters);
|
||||
$payment_summary = get_expenses_manage_payments_summary($payments, $expenses);
|
||||
$data_rows = [];
|
||||
|
||||
foreach($expenses->getResult() as $expense)
|
||||
{
|
||||
$data_rows[] = get_expenses_data_row($expense);
|
||||
}
|
||||
|
||||
if($total_rows > 0)
|
||||
{
|
||||
$data_rows[] = get_expenses_data_last_row($expenses);
|
||||
}
|
||||
|
||||
echo json_encode (['total' => $total_rows, 'rows' => $data_rows, 'payment_summary' => $payment_summary]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $expense_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $expense_id = NEW_ENTRY): void
|
||||
{
|
||||
$data = []; //TODO: Duplicated code
|
||||
|
||||
$data['employees'] = [];
|
||||
foreach($this->employee->get_all()->getResult() as $employee)
|
||||
{
|
||||
foreach(get_object_vars($employee) as $property => $value)
|
||||
{
|
||||
$employee->$property = $value;
|
||||
}
|
||||
|
||||
$data['employees'][$employee->person_id] = $employee->first_name . ' ' . $employee->last_name;
|
||||
}
|
||||
|
||||
$data['expenses_info'] = $this->expense->get_info($expense_id);
|
||||
|
||||
$expense_categories = [];
|
||||
foreach($this->expense_category->get_all(0, 0, true)->getResultArray() as $row)
|
||||
{
|
||||
$expense_categories[$row['expense_category_id']] = $row['category_name'];
|
||||
}
|
||||
$data['expense_categories'] = $expense_categories;
|
||||
|
||||
$expense_id = $data['expenses_info']->expense_id;
|
||||
|
||||
if($expense_id == NEW_ENTRY)
|
||||
{
|
||||
$data['expenses_info']->date = date('Y-m-d H:i:s');
|
||||
$data['expenses_info']->employee_id = $this->employee->get_logged_in_employee_info()->person_id;
|
||||
}
|
||||
|
||||
$data['payments'] = [];
|
||||
foreach($this->expense->get_expense_payment($expense_id)->getResult() as $payment)
|
||||
{
|
||||
foreach(get_object_vars($payment) as $property => $value)
|
||||
{
|
||||
$payment->$property = $value;
|
||||
}
|
||||
|
||||
$data['payments'][] = $payment;
|
||||
}
|
||||
|
||||
// don't allow gift card to be a payment option in a sale transaction edit because it's a complex change
|
||||
$data['payment_options'] = $this->expense->get_payment_options();
|
||||
|
||||
echo view("expenses/form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $row_id
|
||||
* @return void
|
||||
*/
|
||||
public function getRow(int $row_id): void
|
||||
{
|
||||
$expense_info = $this->expense->get_info($row_id);
|
||||
$data_row = get_expenses_data_row($expense_info);
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $expense_id
|
||||
* @return void
|
||||
*/
|
||||
public function postSave(int $expense_id = NEW_ENTRY): void
|
||||
{
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$newdate = $this->request->getPost('date', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$date_formatter = date_create_from_format($config['dateformat'] . ' ' . $config['timeformat'], $newdate);
|
||||
$amount = prepare_decimal($this->request->getPost('amount'));
|
||||
$tax_amount = prepare_decimal($this->request->getPost('tax_amount'));
|
||||
|
||||
$expense_data = [
|
||||
'date' => $date_formatter->format('Y-m-d H:i:s'),
|
||||
'supplier_id' => $this->request->getPost('supplier_id') == '' ? null : $this->request->getPost('supplier_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'supplier_tax_code' => $this->request->getPost('supplier_tax_code', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'amount' => filter_var($amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'tax_amount' => filter_var($tax_amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'payment_type' => $this->request->getPost('payment_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'expense_category_id' => $this->request->getPost('expense_category_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'description' => $this->request->getPost('description', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'employee_id' => $this->request->getPost('employee_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'deleted' => $this->request->getPost('deleted') != null
|
||||
];
|
||||
|
||||
if($this->expense->save_value($expense_data, $expense_id))
|
||||
{
|
||||
//New Expense
|
||||
if($expense_id == NEW_ENTRY)
|
||||
{
|
||||
echo json_encode (['success' => true, 'message' => lang('Expenses.successful_adding'), 'id' => $expense_data['expense_id']]);
|
||||
}
|
||||
else // Existing Expense
|
||||
{
|
||||
echo json_encode (['success' => true, 'message' => lang('Expenses.successful_updating'), 'id' => $expense_id]);
|
||||
}
|
||||
}
|
||||
else//failure
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Expenses.error_adding_updating'), 'id' => NEW_ENTRY]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the expense amount for validity. Used in app\Views\expenses\form.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function ajax_check_amount(): void
|
||||
{
|
||||
$value = $this->request->getPost();
|
||||
$parsed_value = filter_var(prepare_decimal(array_pop($value)), FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
echo json_encode (['success' => $parsed_value !== false]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$expenses_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
if($this->expense->delete_list($expenses_to_delete))
|
||||
{
|
||||
echo json_encode (['success' => true, 'message' => lang('Expenses.successful_deleted') . ' ' . count($expenses_to_delete) . ' ' . lang('Expenses.one_or_multiple'), 'ids' => $expenses_to_delete]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Expenses.cannot_be_deleted'), 'ids' => $expenses_to_delete]);
|
||||
}
|
||||
}
|
||||
}
|
||||
133
app/Controllers/Expenses_categories.php
Normal file
133
app/Controllers/Expenses_categories.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Expense_category;
|
||||
|
||||
class Expenses_categories extends Secure_Controller //TODO: Is this class ever used?
|
||||
{
|
||||
private Expense_category $expense_category;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('expenses_categories');
|
||||
|
||||
$this->expense_category = model(Expense_category::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['table_headers'] = get_expense_category_manage_table_headers();
|
||||
|
||||
echo view('expenses_categories/manage', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns expense_category_manage table data rows. This will be called with AJAX.
|
||||
**/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$expense_categories = $this->expense_category->search($search, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->expense_category->get_found_rows($search);
|
||||
|
||||
$data_rows = [];
|
||||
foreach($expense_categories->getResult() as $expense_category)
|
||||
{
|
||||
$data_rows[] = get_expense_category_data_row($expense_category);
|
||||
}
|
||||
|
||||
echo json_encode (['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $row_id
|
||||
* @return void
|
||||
*/
|
||||
public function getRow(int $row_id): void
|
||||
{
|
||||
$data_row = get_expense_category_data_row($this->expense_category->get_info($row_id));
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $expense_category_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $expense_category_id = NEW_ENTRY): void
|
||||
{
|
||||
$data['category_info'] = $this->expense_category->get_info($expense_category_id);
|
||||
|
||||
echo view("expenses_categories/form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $expense_category_id
|
||||
* @return void
|
||||
*/
|
||||
public function postSave(int $expense_category_id = NEW_ENTRY): void
|
||||
{
|
||||
$expense_category_data = [
|
||||
'category_name' => $this->request->getPost('category_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'category_description' => $this->request->getPost('category_description', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
|
||||
];
|
||||
|
||||
if($this->expense_category->save_value($expense_category_data, $expense_category_id))
|
||||
{
|
||||
// New expense_category
|
||||
if($expense_category_id == NEW_ENTRY)
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Expenses_categories.successful_adding'),
|
||||
'id' => $expense_category_data['expense_category_id']
|
||||
]);
|
||||
}
|
||||
else // Existing Expense Category
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Expenses_categories.successful_updating'),
|
||||
'id' => $expense_category_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
else//failure
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Expenses_categories.error_adding_updating') . ' ' . $expense_category_data['category_name'],
|
||||
'id' => NEW_ENTRY
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$expense_category_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
if($this->expense_category->delete_list($expense_category_to_delete)) //TODO: Convert to ternary notation.
|
||||
{
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => lang('Expenses_categories.successful_deleted') . ' ' . count($expense_category_to_delete) . ' ' . lang('Expenses_categories.one_or_multiple')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Expenses_categories.cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
196
app/Controllers/Giftcards.php
Normal file
196
app/Controllers/Giftcards.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Giftcard;
|
||||
use Config\OSPOS;
|
||||
|
||||
class Giftcards extends Secure_Controller
|
||||
{
|
||||
private Giftcard $giftcard;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('giftcards');
|
||||
|
||||
$this->giftcard = model(Giftcard::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['table_headers'] = get_giftcards_manage_table_headers();
|
||||
|
||||
echo view('giftcards/manage', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Giftcards table data rows. This will be called with AJAX.
|
||||
*/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$giftcards = $this->giftcard->search($search, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->giftcard->get_found_rows($search);
|
||||
|
||||
$data_rows = [];
|
||||
foreach($giftcards->getResult() as $giftcard)
|
||||
{
|
||||
$data_rows[] = get_giftcard_data_row($giftcard);
|
||||
}
|
||||
|
||||
echo json_encode (['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets search suggestions for giftcards. Used in app\Views\sales\register.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getSuggest(): void
|
||||
{
|
||||
$suggestions = $this->giftcard->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), true);
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function suggest_search(): void
|
||||
{
|
||||
$suggestions = $this->giftcard->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $row_id
|
||||
* @return void
|
||||
*/
|
||||
public function getRow(int $row_id): void
|
||||
{
|
||||
$data_row = get_giftcard_data_row($this->giftcard->get_info($row_id));
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $giftcard_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $giftcard_id = NEW_ENTRY): void
|
||||
{
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$giftcard_info = $this->giftcard->get_info($giftcard_id);
|
||||
|
||||
$data['selected_person_name'] = ($giftcard_id > 0 && isset($giftcard_info->person_id)) ? $giftcard_info->first_name . ' ' . $giftcard_info->last_name : '';
|
||||
$data['selected_person_id'] = $giftcard_info->person_id;
|
||||
if($config['giftcard_number'] == 'random')
|
||||
{
|
||||
$data['giftcard_number'] = $giftcard_id > 0 ? $giftcard_info->giftcard_number : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$max_number_obj = $this->giftcard->get_max_number();
|
||||
$max_giftnumber = isset($max_number_obj) ? $this->giftcard->get_max_number()->giftcard_number : 0; //TODO: variable does not follow naming standard.
|
||||
$data['giftcard_number'] = $giftcard_id > 0 ? $giftcard_info->giftcard_number : $max_giftnumber + 1;
|
||||
}
|
||||
$data['giftcard_id'] = $giftcard_id;
|
||||
$data['giftcard_value'] = $giftcard_info->value;
|
||||
|
||||
echo view("giftcards/form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $giftcard_id
|
||||
* @return void
|
||||
*/
|
||||
public function postSave(int $giftcard_id = NEW_ENTRY): void
|
||||
{
|
||||
$giftcard_number = $this->request->getPost('giftcard_number', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$giftcard_amount = prepare_decimal($this->request->getPost('giftcard_amount'));
|
||||
|
||||
if($giftcard_id == NEW_ENTRY && trim($giftcard_number) == '')
|
||||
{
|
||||
$giftcard_number = $this->giftcard->generate_unique_giftcard_name(filter_var($giftcard_amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
}
|
||||
|
||||
$giftcard_data = [
|
||||
'record_time' => date('Y-m-d H:i:s'),
|
||||
'giftcard_number' => $giftcard_number,
|
||||
'value' => filter_var($giftcard_amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'person_id' => $this->request->getPost('person_id') == '' ? null : $this->request->getPost('person_id', FILTER_SANITIZE_NUMBER_INT)
|
||||
];
|
||||
|
||||
if($this->giftcard->save_value($giftcard_data, $giftcard_id))
|
||||
{
|
||||
//New giftcard
|
||||
if($giftcard_id == NEW_ENTRY) //TODO: Constant needed
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Giftcards.successful_adding') . ' ' . $giftcard_data['giftcard_number'],
|
||||
'id' => $giftcard_data['giftcard_id']
|
||||
]);
|
||||
}
|
||||
else //Existing giftcard
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Giftcards.successful_updating') . ' ' . $giftcard_data['giftcard_number'],
|
||||
'id' => $giftcard_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
else //failure
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Giftcards.error_adding_updating') . ' ' . $giftcard_data['giftcard_number'],
|
||||
'id' => NEW_ENTRY
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the giftcard number validity. Used in app\Views\giftcards\form.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postCheckNumberGiftcard(): void
|
||||
{
|
||||
$giftcard_amount = prepare_decimal($this->request->getPost('giftcard_amount'));
|
||||
$parsed_value = filter_var($giftcard_amount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
echo json_encode (['success' => $parsed_value !== false, 'giftcard_amount' => to_currency_no_money($parsed_value)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$giftcards_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
if($this->giftcard->delete_list($giftcards_to_delete))
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Giftcards.successful_deleted') . ' ' . count($giftcards_to_delete).' '.lang('Giftcards.one_or_multiple')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Giftcards.cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
102
app/Controllers/Home.php
Normal file
102
app/Controllers/Home.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
|
||||
class Home extends Secure_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('home', null, 'home');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$logged_in = $this->employee->is_logged_in();
|
||||
echo view('home/home');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the currently logged in employee out of the system. Used in app/Views/partial/header.php
|
||||
*
|
||||
* @return RedirectResponse
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getLogout(): RedirectResponse
|
||||
{
|
||||
$this->employee->logout();
|
||||
return redirect()->to('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load "change employee password" form
|
||||
*
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getChangePassword(int $employee_id = -1): void //TODO: Replace -1 with a constant
|
||||
{
|
||||
$person_info = $this->employee->get_info($employee_id);
|
||||
foreach(get_object_vars($person_info) as $property => $value)
|
||||
{
|
||||
$person_info->$property = $value;
|
||||
}
|
||||
$data['person_info'] = $person_info;
|
||||
|
||||
echo view('home/form_change_password', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change employee password
|
||||
*/
|
||||
public function save(int $employee_id = -1): void //TODO: Replace -1 with a constant
|
||||
{
|
||||
if(!empty($this->request->getPost('current_password')) && $employee_id != -1)
|
||||
{
|
||||
if($this->employee->check_password($this->request->getPost('username', FILTER_SANITIZE_FULL_SPECIAL_CHARS), $this->request->getPost('current_password')))
|
||||
{
|
||||
$employee_data = [
|
||||
'username' => $this->request->getPost('username', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'password' => password_hash($this->request->getPost('password'), PASSWORD_DEFAULT),
|
||||
'hash_version' => 2
|
||||
];
|
||||
|
||||
if($this->employee->change_password($employee_data, $employee_id))
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Employees.successful_change_password'),
|
||||
'id' => $employee_id
|
||||
]);
|
||||
}
|
||||
else//failure
|
||||
{//TODO: Replace -1 with constant
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Employees.unsuccessful_change_password'),
|
||||
'id' => -1
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{//TODO: Replace -1 with constant
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Employees.current_password_invalid'),
|
||||
'id' => -1
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{//TODO: Replace -1 with constant
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Employees.current_password_invalid'),
|
||||
'id' => -1
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
319
app/Controllers/Item_kits.php
Normal file
319
app/Controllers/Item_kits.php
Normal file
@@ -0,0 +1,319 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Libraries\Barcode_lib;
|
||||
|
||||
use App\Models\Item;
|
||||
use App\Models\Item_kit;
|
||||
use App\Models\Item_kit_items;
|
||||
|
||||
class Item_kits extends Secure_Controller
|
||||
{
|
||||
private Item $item;
|
||||
private Item_kit $item_kit;
|
||||
private Item_kit_items $item_kit_items;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('item_kits');
|
||||
|
||||
$this->item = model(Item::class);
|
||||
$this->item_kit = model(Item_kit::class);
|
||||
$this->item_kit_items = model(Item_kit_items::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the total cost and retail price to a passed item_kit retrieving the data from each singular item part of the kit
|
||||
*/
|
||||
private function _add_totals_to_item_kit(object $item_kit): object //TODO: Hungarian notation
|
||||
{
|
||||
$kit_item_info = $this->item->get_info($item_kit->kit_item_id ?? $item_kit->item_id);
|
||||
|
||||
$item_kit->total_cost_price = 0;
|
||||
$item_kit->total_unit_price = $kit_item_info->unit_price;
|
||||
$total_quantity = 0;
|
||||
|
||||
foreach($this->item_kit_items->get_info($item_kit->item_kit_id) as $item_kit_item)
|
||||
{
|
||||
$item_info = $this->item->get_info($item_kit_item['item_id']);
|
||||
foreach(get_object_vars($item_info) as $property => $value)
|
||||
{
|
||||
$item_info->$property = $value;
|
||||
}
|
||||
|
||||
$item_kit->total_cost_price += $item_info->cost_price * $item_kit_item['quantity'];
|
||||
|
||||
if($item_kit->price_option == PRICE_OPTION_ALL || ($item_kit->price_option == PRICE_OPTION_KIT_STOCK && $item_info->stock_type == HAS_STOCK ))
|
||||
{
|
||||
$item_kit->total_unit_price += $item_info->unit_price * $item_kit_item['quantity'];
|
||||
$total_quantity += $item_kit_item['quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
$discount_fraction = bcdiv($item_kit->kit_discount, '100');
|
||||
|
||||
$item_kit->total_unit_price = $item_kit->total_unit_price - round(($item_kit->kit_discount_type == PERCENT)
|
||||
? bcmul($item_kit->total_unit_price, $discount_fraction)
|
||||
: $item_kit->kit_discount, totals_decimals(), PHP_ROUND_HALF_UP);
|
||||
|
||||
return $item_kit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['table_headers'] = get_item_kits_manage_table_headers();
|
||||
|
||||
echo view('item_kits/manage', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Item_kit table data rows. This will be called with AJAX.
|
||||
*/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$item_kits = $this->item_kit->search($search, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->item_kit->get_found_rows($search);
|
||||
|
||||
$data_rows = [];
|
||||
foreach($item_kits->getResult() as $item_kit)
|
||||
{
|
||||
// calculate the total cost and retail price of the Kit, so it can be printed out in the manage table
|
||||
$item_kit = $this->_add_totals_to_item_kit($item_kit);
|
||||
$data_rows[] = get_item_kit_data_row($item_kit);
|
||||
}
|
||||
|
||||
echo json_encode (['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function suggest_search(): void
|
||||
{
|
||||
$suggestions = $this->item_kit->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $row_id
|
||||
* @return void
|
||||
*/
|
||||
public function getRow(int $row_id): void
|
||||
{
|
||||
// calculate the total cost and retail price of the Kit, so it can be added to the table refresh
|
||||
$item_kit = $this->_add_totals_to_item_kit($this->item_kit->get_info($row_id));
|
||||
|
||||
echo json_encode(get_item_kit_data_row($item_kit));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $item_kit_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $item_kit_id = NEW_ENTRY): void
|
||||
{
|
||||
$info = $this->item_kit->get_info($item_kit_id);
|
||||
|
||||
if($item_kit_id == NEW_ENTRY)
|
||||
{
|
||||
$info->price_option = '0';
|
||||
$info->print_option = PRINT_ALL;
|
||||
$info->kit_item_id = 0;
|
||||
$info->item_number = '';
|
||||
$info->kit_discount = 0;
|
||||
}
|
||||
|
||||
foreach(get_object_vars($info) as $property => $value)
|
||||
{
|
||||
$info->$property = $value;
|
||||
}
|
||||
|
||||
$data['item_kit_info'] = $info;
|
||||
|
||||
$items = [];
|
||||
|
||||
foreach($this->item_kit_items->get_info($item_kit_id) as $item_kit_item)
|
||||
{
|
||||
$item['kit_sequence'] = $item_kit_item['kit_sequence'];
|
||||
$item['name'] = $this->item->get_info($item_kit_item['item_id'])->name;
|
||||
$item['item_id'] = $item_kit_item['item_id'];
|
||||
$item['quantity'] = $item_kit_item['quantity'];
|
||||
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
$data['item_kit_items'] = $items;
|
||||
|
||||
$data['selected_kit_item_id'] = $info->kit_item_id;
|
||||
$data['selected_kit_item'] = ($item_kit_id > 0 && isset($info->kit_item_id)) ? $info->item_name : '';
|
||||
|
||||
echo view("item_kits/form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $item_kit_id
|
||||
* @return void
|
||||
*/
|
||||
public function postSave(int $item_kit_id = NEW_ENTRY): void
|
||||
{
|
||||
$kit_discount = prepare_decimal($this->request->getPost('kit_discount'));
|
||||
|
||||
$item_kit_data = [
|
||||
'name' => $this->request->getPost('name'),
|
||||
'item_kit_number' => $this->request->getPost('item_kit_number'),
|
||||
'item_id' => $this->request->getPost('kit_item_id') ? null : intval($this->request->getPost('kit_item_id')),
|
||||
'kit_discount' => filter_var($kit_discount,FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION),
|
||||
'kit_discount_type' => $this->request->getPost('kit_discount_type') === null ? PERCENT : intval($this->request->getPost('kit_discount_type')),
|
||||
'price_option' => $this->request->getPost('price_option') === null ? PRICE_ALL : intval($this->request->getPost('price_option')),
|
||||
'print_option' => $this->request->getPost('print_option') === null ? PRINT_ALL : intval($this->request->getPost('print_option')),
|
||||
'description' => $this->request->getPost('description')
|
||||
];
|
||||
|
||||
if($this->item_kit->save_value($item_kit_data, $item_kit_id))
|
||||
{
|
||||
$new_item = false;
|
||||
//New item kit
|
||||
if($item_kit_id == NEW_ENTRY)
|
||||
{
|
||||
$item_kit_id = $item_kit_data['item_kit_id'];
|
||||
$new_item = true;
|
||||
}
|
||||
|
||||
$item_kit_items_array = $this->request->getPost('item_kit_qty') === null ? null : $this->request->getPost('item_kit_qty');
|
||||
|
||||
if($item_kit_items_array != null)
|
||||
{
|
||||
$item_kit_items = [];
|
||||
foreach($item_kit_items_array as $item_id => $item_kit_qty)
|
||||
{
|
||||
$item_kit_items[] = [
|
||||
'item_id' => $item_id,
|
||||
'quantity' => $item_kit_qty === null ? 0 : parse_quantity($item_kit_qty),
|
||||
'kit_sequence' => $this->request->getPost("item_kit_seq[$item_id]") === null ? 0 : intval($this->request->getPost("item_kit_seq[$item_id]"))
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($item_kit_items))
|
||||
{
|
||||
$success = $this->item_kit_items->save_value($item_kit_items, $item_kit_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$success = true;
|
||||
}
|
||||
|
||||
if($new_item)
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => $success,
|
||||
'message' => lang('Item_kits.successful_adding').' '.$item_kit_data['name'],
|
||||
'id' => $item_kit_id
|
||||
]);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => $success,
|
||||
'message' => lang('Item_kits.successful_updating').' '.$item_kit_data['name'],
|
||||
'id' => $item_kit_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
else//failure
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Item_kits.error_adding_updating') . ' ' . $item_kit_data['name'],
|
||||
'id' => NEW_ENTRY
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$item_kits_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
if($this->item_kit->delete_list($item_kits_to_delete))
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Item_kits.successful_deleted') . ' ' . count($item_kits_to_delete) . ' ' . lang('Item_kits.one_or_multiple')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Item_kits.cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the validity of the item kit number. Used in app/Views/item_kits/form.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postCheckItemNumber(): void
|
||||
{
|
||||
$exists = $this->item_kit->item_number_exists($this->request->getPost('item_kit_number', FILTER_SANITIZE_FULL_SPECIAL_CHARS), $this->request->getPost('item_kit_id', FILTER_SANITIZE_NUMBER_INT));
|
||||
echo !$exists ? 'true' : 'false';
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX called function that generates barcodes for selected item_kits.
|
||||
*
|
||||
* @param string $item_kit_ids Colon separated list of item_kit_id values to generate barcodes for.
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getGenerateBarcodes(string $item_kit_ids): void
|
||||
{
|
||||
$barcode_lib = new Barcode_lib();
|
||||
$result = [];
|
||||
|
||||
$item_kit_ids = explode(':', $item_kit_ids);
|
||||
foreach($item_kit_ids as $item_kid_id)
|
||||
{
|
||||
// calculate the total cost and retail price of the Kit, so it can be added to the barcode text at the bottom
|
||||
$item_kit = $this->_add_totals_to_item_kit($this->item_kit->get_info($item_kid_id));
|
||||
|
||||
$item_kid_id = 'KIT '. urldecode($item_kid_id);
|
||||
|
||||
$result[] = [
|
||||
'name' => $item_kit->name,
|
||||
'item_id' => $item_kid_id,
|
||||
'item_number' => $item_kid_id,
|
||||
'cost_price' => $item_kit->total_cost_price,
|
||||
'unit_price' => $item_kit->total_unit_price
|
||||
];
|
||||
}
|
||||
|
||||
$data['items'] = $result;
|
||||
$barcode_config = $barcode_lib->get_barcode_config();
|
||||
// in case the selected barcode type is not Code39 or Code128 we set by default Code128
|
||||
// the rationale for this is that EAN codes cannot have strings as seed, so 'KIT ' is not allowed
|
||||
if($barcode_config['barcode_type'] != 'C39' && $barcode_config['barcode_type'] != 'C128')
|
||||
{
|
||||
$barcode_config['barcode_type'] = 'C128';
|
||||
}
|
||||
$data['barcode_config'] = $barcode_config;
|
||||
|
||||
// display barcodes
|
||||
echo view("barcodes/barcode_sheet", $data);
|
||||
}
|
||||
}
|
||||
1444
app/Controllers/Items.php
Normal file
1444
app/Controllers/Items.php
Normal file
File diff suppressed because it is too large
Load Diff
78
app/Controllers/Login.php
Normal file
78
app/Controllers/Login.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Libraries\MY_Migration;
|
||||
use App\Models\Employee;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\Model;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* @property employee employee
|
||||
*/
|
||||
class Login extends BaseController
|
||||
{
|
||||
public Model $employee;
|
||||
|
||||
/**
|
||||
* @return RedirectResponse|string
|
||||
*/
|
||||
public function index(): string|RedirectResponse
|
||||
{
|
||||
$this->employee = model(Employee::class);
|
||||
if(!$this->employee->is_logged_in())
|
||||
{
|
||||
$migration = new MY_Migration(config('Migrations'));
|
||||
$config = config(OSPOS::class)->settings;
|
||||
|
||||
$gcaptcha_enabled = array_key_exists('gcaptcha_enable', $config)
|
||||
? $config['gcaptcha_enable']
|
||||
: false;
|
||||
|
||||
$migration->migrate_to_ci4();
|
||||
|
||||
$validation = Services::validation();
|
||||
|
||||
$data = [
|
||||
'has_errors' => false,
|
||||
'is_latest' => $migration->is_latest(),
|
||||
'latest_version' => $migration->get_latest_migration(),
|
||||
'gcaptcha_enabled' => $gcaptcha_enabled,
|
||||
'config' => $config,
|
||||
'validation' => $validation
|
||||
];
|
||||
|
||||
if($this->request->getMethod() !== 'POST')
|
||||
{
|
||||
return view('login', $data);
|
||||
}
|
||||
|
||||
$rules = ['username' => 'required|login_check[data]'];
|
||||
$messages = [
|
||||
'username' => [
|
||||
'required' => lang('Login.required_username'),
|
||||
'login_check' => lang('Login.invalid_username_and_password'),
|
||||
]
|
||||
];
|
||||
|
||||
if(!$this->validate($rules, $messages))
|
||||
{
|
||||
$data['has_errors'] = !empty($validation->getErrors());
|
||||
|
||||
return view('login', $data);
|
||||
}
|
||||
|
||||
if(!$data['is_latest'])
|
||||
{
|
||||
set_time_limit(3600);
|
||||
|
||||
$migration->setNamespace('App')->latest();
|
||||
return redirect()->to('login');
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->to('home');
|
||||
}
|
||||
}
|
||||
97
app/Controllers/Messages.php
Normal file
97
app/Controllers/Messages.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Libraries\Sms_lib;
|
||||
|
||||
use App\Models\Person;
|
||||
|
||||
class Messages extends Secure_Controller
|
||||
{
|
||||
private Sms_lib $sms_lib;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('messages');
|
||||
|
||||
$this->sms_lib = new Sms_lib();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
echo view('messages/sms');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $person_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $person_id = NEW_ENTRY): void
|
||||
{
|
||||
$person = model(Person::class);
|
||||
$info = $person->get_info($person_id);
|
||||
|
||||
foreach(get_object_vars($info) as $property => $value)
|
||||
{
|
||||
$info->$property = $value;
|
||||
}
|
||||
$data['person_info'] = $info;
|
||||
|
||||
echo view('messages/form_sms', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function send(): void
|
||||
{
|
||||
$phone = $this->request->getPost('phone', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$message = $this->request->getPost('message', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$response = $this->sms_lib->sendSMS($phone, $message);
|
||||
|
||||
if($response)
|
||||
{
|
||||
echo json_encode (['success' => true, 'message' => lang('Messages.successfully_sent') . ' ' . esc($phone)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Messages.unsuccessfully_sent') . ' ' . esc($phone)]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends an SMS message to a user. Used in app/Views/messages/form_sms.php.
|
||||
*
|
||||
* @param int $person_id
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function send_form(int $person_id = NEW_ENTRY): void
|
||||
{
|
||||
$phone = $this->request->getPost('phone', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$message = $this->request->getPost('message', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$response = $this->sms_lib->sendSMS($phone, $message);
|
||||
|
||||
if($response)
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Messages.successfully_sent') . ' ' . esc($phone),
|
||||
'person_id' => $person_id
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Messages.unsuccessfully_sent') . ' ' . esc($phone),
|
||||
'person_id' => NEW_ENTRY
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
34
app/Controllers/No_access.php
Normal file
34
app/Controllers/No_access.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Module;
|
||||
|
||||
/**
|
||||
* Part of the grants mechanism to restrict access to modules that the user doesn't have permission for.
|
||||
* Instantiated in the views.
|
||||
*
|
||||
* @property module module
|
||||
*/
|
||||
class No_access extends BaseController
|
||||
{
|
||||
private Module $module;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->module = model(Module::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $module_id
|
||||
* @param string $permission_id
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(string $module_id = '', string $permission_id = ''): void
|
||||
{
|
||||
$data['module_name'] = $this->module->get_module_name($module_id);
|
||||
$data['permission_id'] = $permission_id;
|
||||
|
||||
echo view('no_access', $data);
|
||||
}
|
||||
}
|
||||
36
app/Controllers/Office.php
Normal file
36
app/Controllers/Office.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Employee;
|
||||
|
||||
/**
|
||||
* @property Employee employee
|
||||
*/
|
||||
class Office extends Secure_Controller
|
||||
{
|
||||
protected Employee $employee;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('office', null, 'office');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
echo view('home/office');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function logout(): void
|
||||
{
|
||||
$this->employee = model(Employee::class);
|
||||
|
||||
$this->employee->logout();
|
||||
}
|
||||
}
|
||||
69
app/Controllers/Persons.php
Normal file
69
app/Controllers/Persons.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Person;
|
||||
use function Tamtamchik\NameCase\str_name_case;
|
||||
|
||||
abstract class Persons extends Secure_Controller
|
||||
{
|
||||
protected Person $person;
|
||||
|
||||
/**
|
||||
* @param string|null $module_id
|
||||
*/
|
||||
public function __construct(string $module_id = null)
|
||||
{
|
||||
parent::__construct($module_id);
|
||||
|
||||
$this->person = model(Person::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['table_headers'] = get_people_manage_table_headers();
|
||||
|
||||
echo view('people/manage', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives search suggestions based on what is being searched for
|
||||
*/
|
||||
public function getSuggest(): void
|
||||
{
|
||||
$suggestions = $this->person->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets one row for a person manage table. This is called using AJAX to update one row.
|
||||
*/
|
||||
public function getRow(int $row_id): void
|
||||
{
|
||||
$data_row = get_person_data_row($this->person->get_info($row_id));
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Capitalize segments of a name, and put the rest into lower case.
|
||||
* You can pass the characters you want to use as delimiters as exceptions.
|
||||
* The function supports UTF-8 strings
|
||||
*
|
||||
* Example:
|
||||
* i.e. <?php echo nameize("john o'grady-smith"); ?>
|
||||
*
|
||||
* returns John O'Grady-Smith
|
||||
*/
|
||||
protected function nameize(string $input): string
|
||||
{
|
||||
$adjusted_name = str_name_case($input);
|
||||
|
||||
// Use preg_replace to match HTML entities and convert them to lowercase.
|
||||
return preg_replace_callback('/&[a-zA-Z0-9#]+;/', function($matches) { return strtolower($matches[0]); }, $adjusted_name);
|
||||
}
|
||||
}
|
||||
561
app/Controllers/Receivings.php
Normal file
561
app/Controllers/Receivings.php
Normal file
@@ -0,0 +1,561 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Libraries\Receiving_lib;
|
||||
use App\Libraries\Token_lib;
|
||||
use App\Libraries\Barcode_lib;
|
||||
use App\Models\Inventory;
|
||||
use App\Models\Item;
|
||||
use App\Models\Item_kit;
|
||||
use App\Models\Receiving;
|
||||
use App\Models\Stock_location;
|
||||
use App\Models\Supplier;
|
||||
use Config\OSPOS;
|
||||
use ReflectionException;
|
||||
|
||||
class Receivings extends Secure_Controller
|
||||
{
|
||||
private Receiving_lib $receiving_lib;
|
||||
private Token_lib $token_lib;
|
||||
private Barcode_lib $barcode_lib;
|
||||
private Inventory $inventory;
|
||||
private Item $item;
|
||||
private Item_kit $item_kit;
|
||||
private Receiving $receiving;
|
||||
private Stock_location $stock_location;
|
||||
private Supplier $supplier;
|
||||
private array $config;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('receivings');
|
||||
|
||||
$this->receiving_lib = new Receiving_lib();
|
||||
$this->token_lib = new Token_lib();
|
||||
$this->barcode_lib = new Barcode_lib();
|
||||
|
||||
$this->inventory = model(Inventory::class);
|
||||
$this->item_kit = model(Item_kit::class);
|
||||
$this->item = model(Item::class);
|
||||
$this->receiving = model(Receiving::class);
|
||||
$this->stock_location = model(Stock_location::class);
|
||||
$this->supplier = model(Supplier::class);
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$this->_reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns search suggestions for an item. Used in app/Views/sales/register.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getItemSearch(): void
|
||||
{
|
||||
$suggestions = $this->item->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), ['search_custom' => false, 'is_deleted' => false], true);
|
||||
$suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)));
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets search suggestions for a stock item. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getStockItemSearch(): void
|
||||
{
|
||||
$suggestions = $this->item->get_stock_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), ['search_custom' => false, 'is_deleted' => false], true);
|
||||
$suggestions = array_merge($suggestions, $this->item_kit->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)));
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set supplier if it exists in the database. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postSelectSupplier(): void
|
||||
{
|
||||
$supplier_id = $this->request->getPost('supplier', FILTER_SANITIZE_NUMBER_INT);
|
||||
if($this->supplier->exists($supplier_id))
|
||||
{
|
||||
$this->receiving_lib->set_supplier($supplier_id);
|
||||
}
|
||||
|
||||
$this->_reload(); //TODO: Hungarian notation
|
||||
}
|
||||
|
||||
/**
|
||||
* Change receiving mode for current receiving. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postChangeMode(): void
|
||||
{
|
||||
$stock_destination = $this->request->getPost('stock_destination', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$stock_source = $this->request->getPost('stock_source', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
if((!$stock_source || $stock_source == $this->receiving_lib->get_stock_source()) &&
|
||||
(!$stock_destination || $stock_destination == $this->receiving_lib->get_stock_destination()))
|
||||
{
|
||||
$this->receiving_lib->clear_reference();
|
||||
$mode = $this->request->getPost('mode', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$this->receiving_lib->set_mode($mode);
|
||||
}
|
||||
elseif($this->stock_location->is_allowed_location($stock_source, 'receivings'))
|
||||
{
|
||||
$this->receiving_lib->set_stock_source($stock_source);
|
||||
$this->receiving_lib->set_stock_destination($stock_destination);
|
||||
}
|
||||
|
||||
$this->_reload(); //TODO: Hungarian notation
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets receiving comment. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postSetComment(): void
|
||||
{
|
||||
$this->receiving_lib->set_comment($this->request->getPost('comment', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the print after sale flag for the receiving. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postSetPrintAfterSale(): void
|
||||
{
|
||||
$this->receiving_lib->set_print_after_sale($this->request->getPost('recv_print_after_sale') != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the reference number for the receiving. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postSetReference(): void
|
||||
{
|
||||
$this->receiving_lib->set_reference($this->request->getPost('recv_reference', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item to the receiving. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postAdd(): void
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$mode = $this->receiving_lib->get_mode();
|
||||
$item_id_or_number_or_item_kit_or_receipt = (int)$this->request->getPost('item', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$this->token_lib->parse_barcode($quantity, $price, $item_id_or_number_or_item_kit_or_receipt);
|
||||
$quantity = ($mode == 'receive' || $mode == 'requisition') ? $quantity : -$quantity;
|
||||
$item_location = $this->receiving_lib->get_stock_source();
|
||||
$discount = $this->config['default_receivings_discount'];
|
||||
$discount_type = $this->config['default_receivings_discount_type'];
|
||||
|
||||
if($mode == 'return' && $this->receiving->is_valid_receipt($item_id_or_number_or_item_kit_or_receipt))
|
||||
{
|
||||
$this->receiving_lib->return_entire_receiving($item_id_or_number_or_item_kit_or_receipt);
|
||||
}
|
||||
elseif($this->item_kit->is_valid_item_kit($item_id_or_number_or_item_kit_or_receipt))
|
||||
{
|
||||
$this->receiving_lib->add_item_kit($item_id_or_number_or_item_kit_or_receipt, $item_location, $discount, $discount_type);
|
||||
}
|
||||
elseif(!$this->receiving_lib->add_item($item_id_or_number_or_item_kit_or_receipt, $quantity, $item_location, $discount, $discount_type))
|
||||
{
|
||||
$data['error'] = lang('Receivings.unable_to_add_item');
|
||||
}
|
||||
|
||||
$this->_reload($data); //TODO: Hungarian notation
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit line item in current receiving. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @param $item_id
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postEditItem($item_id): void
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$validation_rule = [
|
||||
'price' => 'trim|required|numeric',
|
||||
'quantity' => 'trim|required|numeric',
|
||||
'discount' => 'trim|required|numeric',
|
||||
];
|
||||
|
||||
$raw_price = prepare_decimal($this->request->getPost('price'));
|
||||
$raw_quantity = prepare_decimal($this->request->getPost('quantity'));
|
||||
$raw_discount = prepare_decimal($this->request->getPost('discount'));
|
||||
$raw_receiving_quantity = prepare_decimal($this->request->getPost('receiving_quantity'));
|
||||
|
||||
$description = $this->request->getPost('description', FILTER_SANITIZE_FULL_SPECIAL_CHARS); //TODO: Duplicated code
|
||||
$serialnumber = $this->request->getPost('serialnumber', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ?? '';
|
||||
$price = filter_var($raw_price, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
$quantity = filter_var($raw_quantity, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
$discount_type = $this->request->getPost('discount_type', FILTER_SANITIZE_NUMBER_INT);
|
||||
$discount = $discount_type
|
||||
? parse_quantity(filter_var($raw_discount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION))
|
||||
: parse_decimals(filter_var($raw_discount, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
|
||||
$receiving_quantity = filter_var($raw_receiving_quantity, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
|
||||
if($this->validate($validation_rule))
|
||||
{
|
||||
$this->receiving_lib->edit_item($item_id, $description, $serialnumber, $quantity, $discount, $discount_type, $price, $receiving_quantity);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['error']=lang('Receivings.error_editing_item');
|
||||
}
|
||||
|
||||
$this->_reload($data); //TODO: Hungarian notation
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a receiving. Used in app/Controllers/Receivings.php
|
||||
*
|
||||
* @param $receiving_id
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getEdit($receiving_id): void
|
||||
{
|
||||
$data = [];
|
||||
|
||||
$data['suppliers'] = ['' => 'No Supplier'];
|
||||
foreach($this->supplier->get_all()->getResult() as $supplier)
|
||||
{
|
||||
$data['suppliers'][$supplier->person_id] = $supplier->first_name . ' ' . $supplier->last_name;
|
||||
}
|
||||
|
||||
$data['employees'] = [];
|
||||
foreach($this->employee->get_all()->getResult() as $employee)
|
||||
{
|
||||
$data['employees'][$employee->person_id] = $employee->first_name . ' '. $employee->last_name;
|
||||
}
|
||||
|
||||
$receiving_info = $this->receiving->get_info($receiving_id)->getRowArray();
|
||||
$data['selected_supplier_name'] = !empty($receiving_info['supplier_id']) ? $receiving_info['company_name'] : '';
|
||||
$data['selected_supplier_id'] = $receiving_info['supplier_id'];
|
||||
$data['receiving_info'] = $receiving_info;
|
||||
|
||||
echo view('receivings/form', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an item from the current receiving. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @param $item_number
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getDeleteItem($item_number): void
|
||||
{
|
||||
$this->receiving_lib->delete_item($item_number);
|
||||
|
||||
$this->_reload(); //TODO: Hungarian notation
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function postDelete(int $receiving_id = -1, bool $update_inventory = true) : void
|
||||
{
|
||||
$employee_id = $this->employee->get_logged_in_employee_info()->person_id;
|
||||
$receiving_ids = $receiving_id == -1 ? $this->request->getPost('ids', FILTER_SANITIZE_NUMBER_INT) : [$receiving_id]; //TODO: Replace -1 with constant
|
||||
|
||||
if($this->receiving->delete_list($receiving_ids, $employee_id, $update_inventory)) //TODO: Likely need to surround this block of code in a try-catch to catch the ReflectionException
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Receivings.successfully_deleted') . ' ' . count($receiving_ids) . ' ' . lang('Receivings.one_or_multiple'),
|
||||
'ids' => $receiving_ids]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Receivings.cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a supplier from a receiving. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getRemoveSupplier(): void
|
||||
{
|
||||
$this->receiving_lib->clear_reference();
|
||||
$this->receiving_lib->remove_supplier();
|
||||
|
||||
$this->_reload(); //TODO: Hungarian notation
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete and finalize receiving. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @throws ReflectionException
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postComplete(): void
|
||||
{
|
||||
$amount_tendered = prepare_decimal($this->request->getPost('amount_tendered'));
|
||||
$data = [];
|
||||
|
||||
$data['cart'] = $this->receiving_lib->get_cart();
|
||||
$data['total'] = $this->receiving_lib->get_total();
|
||||
$data['transaction_time'] = to_datetime(time());
|
||||
$data['mode'] = $this->receiving_lib->get_mode();
|
||||
$data['comment'] = $this->receiving_lib->get_comment();
|
||||
$data['reference'] = $this->receiving_lib->get_reference();
|
||||
$data['payment_type'] = $this->request->getPost('payment_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$data['show_stock_locations'] = $this->stock_location->show_locations('receivings');
|
||||
$data['stock_location'] = $this->receiving_lib->get_stock_source();
|
||||
if($this->request->getPost('amount_tendered') != null)
|
||||
{
|
||||
$data['amount_tendered'] = filter_var($amount_tendered, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
|
||||
$data['amount_change'] = to_currency($data['amount_tendered'] - $data['total']);
|
||||
}
|
||||
|
||||
$employee_id = $this->employee->get_logged_in_employee_info()->person_id;
|
||||
$employee_info = $this->employee->get_info($employee_id);
|
||||
$data['employee'] = $employee_info->first_name . ' ' . $employee_info->last_name;
|
||||
|
||||
$supplier_id = $this->receiving_lib->get_supplier();
|
||||
if($supplier_id != -1)
|
||||
{
|
||||
$supplier_info = $this->supplier->get_info($supplier_id);
|
||||
$data['supplier'] = $supplier_info->company_name; //TODO: duplicated code
|
||||
$data['first_name'] = $supplier_info->first_name;
|
||||
$data['last_name'] = $supplier_info->last_name;
|
||||
$data['supplier_email'] = $supplier_info->email;
|
||||
$data['supplier_address'] = $supplier_info->address_1;
|
||||
if(!empty($supplier_info->zip) or !empty($supplier_info->city))
|
||||
{
|
||||
$data['supplier_location'] = $supplier_info->zip . ' ' . $supplier_info->city;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['supplier_location'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
//SAVE receiving to database
|
||||
$data['receiving_id'] = 'RECV ' . $this->receiving->save_value($data['cart'], $supplier_id, $employee_id, $data['comment'], $data['reference'], $data['payment_type'], $data['stock_location']);
|
||||
|
||||
if($data['receiving_id'] == 'RECV -1')
|
||||
{
|
||||
$data['error_message'] = lang('Receivings.transaction_failed');
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['receiving_id']);
|
||||
}
|
||||
|
||||
$data['print_after_sale'] = $this->receiving_lib->is_print_after_sale();
|
||||
|
||||
echo view("receivings/receipt",$data);
|
||||
|
||||
$this->receiving_lib->clear_all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete a receiving requisition. Used in app/Views/receivings/receiving.php.
|
||||
*
|
||||
* @throws ReflectionException
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postRequisitionComplete(): void
|
||||
{
|
||||
if($this->receiving_lib->get_stock_source() != $this->receiving_lib->get_stock_destination())
|
||||
{
|
||||
foreach($this->receiving_lib->get_cart() as $item)
|
||||
{
|
||||
$this->receiving_lib->delete_item($item['line']);
|
||||
$this->receiving_lib->add_item($item['item_id'], $item['quantity'], $this->receiving_lib->get_stock_destination(), $item['discount_type']);
|
||||
$this->receiving_lib->add_item($item['item_id'], -$item['quantity'], $this->receiving_lib->get_stock_source(), $item['discount_type']);
|
||||
}
|
||||
|
||||
$this->complete();
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['error'] = lang('Receivings.error_requisition');
|
||||
|
||||
$this->_reload($data); //TODO: Hungarian notation
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the receipt for a receiving. Used in app/Views/receivings/form.php
|
||||
*
|
||||
* @param $receiving_id
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getReceipt($receiving_id): void
|
||||
{
|
||||
$receiving_info = $this->receiving->get_info($receiving_id)->getRowArray();
|
||||
$this->receiving_lib->copy_entire_receiving($receiving_id);
|
||||
$data['cart'] = $this->receiving_lib->get_cart();
|
||||
$data['total'] = $this->receiving_lib->get_total();
|
||||
$data['mode'] = $this->receiving_lib->get_mode();
|
||||
$data['transaction_time'] = to_datetime(strtotime($receiving_info['receiving_time']));
|
||||
$data['show_stock_locations'] = $this->stock_location->show_locations('receivings');
|
||||
$data['payment_type'] = $receiving_info['payment_type'];
|
||||
$data['reference'] = $this->receiving_lib->get_reference();
|
||||
$data['receiving_id'] = 'RECV ' . $receiving_id;
|
||||
$data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['receiving_id']);
|
||||
$employee_info = $this->employee->get_info($receiving_info['employee_id']);
|
||||
$data['employee'] = $employee_info->first_name . ' ' . $employee_info->last_name;
|
||||
|
||||
$supplier_id = $this->receiving_lib->get_supplier(); //TODO: Duplicated code
|
||||
if($supplier_id != -1)
|
||||
{
|
||||
$supplier_info = $this->supplier->get_info($supplier_id);
|
||||
$data['supplier'] = $supplier_info->company_name;
|
||||
$data['first_name'] = $supplier_info->first_name;
|
||||
$data['last_name'] = $supplier_info->last_name;
|
||||
$data['supplier_email'] = $supplier_info->email;
|
||||
$data['supplier_address'] = $supplier_info->address_1;
|
||||
if(!empty($supplier_info->zip) or !empty($supplier_info->city))
|
||||
{
|
||||
$data['supplier_location'] = $supplier_info->zip . ' ' . $supplier_info->city;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['supplier_location'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$data['print_after_sale'] = false;
|
||||
|
||||
echo view("receivings/receipt", $data);
|
||||
|
||||
$this->receiving_lib->clear_all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
private function _reload(array $data = []): void //TODO: Hungarian notation
|
||||
{
|
||||
$data['cart'] = $this->receiving_lib->get_cart();
|
||||
$data['modes'] = ['receive' => lang('Receivings.receiving'), 'return' => lang('Receivings.return')];
|
||||
$data['mode'] = $this->receiving_lib->get_mode();
|
||||
$data['stock_locations'] = $this->stock_location->get_allowed_locations('receivings');
|
||||
$data['show_stock_locations'] = count($data['stock_locations']) > 1;
|
||||
if($data['show_stock_locations'])
|
||||
{
|
||||
$data['modes']['requisition'] = lang('Receivings.requisition');
|
||||
$data['stock_source'] = $this->receiving_lib->get_stock_source();
|
||||
$data['stock_destination'] = $this->receiving_lib->get_stock_destination();
|
||||
}
|
||||
|
||||
$data['total'] = $this->receiving_lib->get_total();
|
||||
$data['items_module_allowed'] = $this->employee->has_grant('items', $this->employee->get_logged_in_employee_info()->person_id);
|
||||
$data['comment'] = $this->receiving_lib->get_comment();
|
||||
$data['reference'] = $this->receiving_lib->get_reference();
|
||||
$data['payment_options'] = $this->receiving->get_payment_options();
|
||||
|
||||
$supplier_id = $this->receiving_lib->get_supplier();
|
||||
|
||||
if($supplier_id != -1) //TODO: Duplicated Code... replace -1 with a constant
|
||||
{
|
||||
$supplier_info = $this->supplier->get_info($supplier_id);
|
||||
$data['supplier'] = $supplier_info->company_name;
|
||||
$data['first_name'] = $supplier_info->first_name;
|
||||
$data['last_name'] = $supplier_info->last_name;
|
||||
$data['supplier_email'] = $supplier_info->email;
|
||||
$data['supplier_address'] = $supplier_info->address_1;
|
||||
if(!empty($supplier_info->zip) or !empty($supplier_info->city))
|
||||
{
|
||||
$data['supplier_location'] = $supplier_info->zip . ' ' . $supplier_info->city;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['supplier_location'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$data['print_after_sale'] = $this->receiving_lib->is_print_after_sale();
|
||||
|
||||
echo view("receivings/receiving", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function save(int $receiving_id = -1): void //TODO: Replace -1 with a constant
|
||||
{
|
||||
$newdate = $this->request->getPost('date', FILTER_SANITIZE_FULL_SPECIAL_CHARS); //TODO: newdate does not follow naming conventions
|
||||
|
||||
$date_formatter = date_create_from_format($this->config['dateformat'] . ' ' . $this->config['timeformat'], $newdate);
|
||||
$receiving_time = $date_formatter->format('Y-m-d H:i:s');
|
||||
|
||||
$receiving_data = [
|
||||
'receiving_time' => $receiving_time,
|
||||
'supplier_id' => $this->request->getPost('supplier_id') ? $this->request->getPost('supplier_id', FILTER_SANITIZE_NUMBER_INT) : null,
|
||||
'employee_id' => $this->request->getPost('employee_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'comment' => $this->request->getPost('comment', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'reference' => $this->request->getPost('reference') != '' ? $this->request->getPost('reference', FILTER_SANITIZE_FULL_SPECIAL_CHARS) : null
|
||||
];
|
||||
|
||||
$this->inventory->update('RECV '.$receiving_id, ['trans_date' => $receiving_time]);
|
||||
if($this->receiving->update($receiving_id, $receiving_data))
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Receivings.successfully_updated'),
|
||||
'id' => $receiving_id
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Receivings.unsuccessfully_updated'),
|
||||
'id' => $receiving_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel an in-process receiving. Used in app/Views/receivings/receiving.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function postCancelReceiving(): void
|
||||
{
|
||||
$this->receiving_lib->clear_all();
|
||||
|
||||
$this->_reload(); //TODO: Hungarian Notation
|
||||
}
|
||||
}
|
||||
2195
app/Controllers/Reports.php
Normal file
2195
app/Controllers/Reports.php
Normal file
File diff suppressed because it is too large
Load Diff
1902
app/Controllers/Sales.php
Normal file
1902
app/Controllers/Sales.php
Normal file
File diff suppressed because it is too large
Load Diff
145
app/Controllers/Secure_Controller.php
Normal file
145
app/Controllers/Secure_Controller.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Employee;
|
||||
use App\Models\Module;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use CodeIgniter\Session\Session;
|
||||
use Config\OSPOS;
|
||||
use Config\Services;
|
||||
|
||||
/**
|
||||
* Controllers that are considered secure extend Secure_Controller, optionally a $module_id can
|
||||
* be set to also check if a user can access a particular module in the system.
|
||||
*
|
||||
* @property employee employee
|
||||
* @property module module
|
||||
* @property array global_view_data
|
||||
* @property session session
|
||||
*
|
||||
*/
|
||||
class Secure_Controller extends BaseController
|
||||
{
|
||||
public array $global_view_data;
|
||||
protected Employee $employee;
|
||||
protected Module $module;
|
||||
protected Session $session;
|
||||
|
||||
/**
|
||||
* @param string $module_id
|
||||
* @param string|null $submodule_id
|
||||
* @param string|null $menu_group
|
||||
*/
|
||||
public function __construct(string $module_id = '', string $submodule_id = null, string $menu_group = null)
|
||||
{
|
||||
$this->employee = model(Employee::class);
|
||||
$this->module = model(Module::class);
|
||||
$config = config(OSPOS::class)->settings;
|
||||
$validation = Services::validation();
|
||||
|
||||
if(!$this->employee->is_logged_in())
|
||||
{
|
||||
header("Location:".base_url('login'));
|
||||
exit();
|
||||
}
|
||||
|
||||
$logged_in_employee_info = $this->employee->get_logged_in_employee_info();
|
||||
if(!$this->employee->has_module_grant($module_id, $logged_in_employee_info->person_id)
|
||||
|| (isset($submodule_id) && !$this->employee->has_module_grant($submodule_id, $logged_in_employee_info->person_id)))
|
||||
{
|
||||
header("Location:".base_url("no_access/$module_id/$submodule_id"));
|
||||
exit();
|
||||
}
|
||||
|
||||
// load up global global_view_data visible to all the loaded views
|
||||
$this->session = session();
|
||||
if($menu_group == null)
|
||||
{
|
||||
$menu_group = $this->session->get('menu_group');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session->set('menu_group', $menu_group);
|
||||
}
|
||||
|
||||
$allowed_modules = $menu_group == 'home'
|
||||
? $this->module->get_allowed_home_modules($logged_in_employee_info->person_id)
|
||||
: $this->module->get_allowed_office_modules($logged_in_employee_info->person_id);
|
||||
|
||||
$this->global_view_data = [];
|
||||
foreach($allowed_modules->getResult() as $module)
|
||||
{
|
||||
$this->global_view_data['allowed_modules'][] = $module;
|
||||
}
|
||||
|
||||
$this->global_view_data += [
|
||||
'user_info' => $logged_in_employee_info,
|
||||
'controller_name' => $module_id,
|
||||
'config' => $config
|
||||
];
|
||||
view('viewData', $this->global_view_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX function used to confirm whether values sent in the request are numeric
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getCheckNumeric(): void
|
||||
{
|
||||
$result = true;
|
||||
|
||||
foreach($this->request->getGet(null, FILTER_SANITIZE_FULL_SPECIAL_CHARS) as $value)
|
||||
{
|
||||
$result &= (int)parse_decimals($value);
|
||||
}
|
||||
|
||||
echo $result !== false ? 'true' : 'false';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function getConfig($key)
|
||||
{
|
||||
if (isset($config[$key]))
|
||||
{
|
||||
return $config[$key];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
public function getIndex() { return false; }
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
public function getSearch() { return false; }
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
public function suggest_search() { return false; }
|
||||
|
||||
/**
|
||||
* @param int $data_item_id
|
||||
* @return false
|
||||
*/
|
||||
public function getView(int $data_item_id = -1) { return false; }
|
||||
|
||||
/**
|
||||
* @param int $data_item_id
|
||||
* @return false
|
||||
*/
|
||||
public function postSave(int $data_item_id = -1) { return false; }
|
||||
|
||||
/**
|
||||
* @return false
|
||||
*/
|
||||
public function postDelete() { return false; }
|
||||
}
|
||||
196
app/Controllers/Suppliers.php
Normal file
196
app/Controllers/Suppliers.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Supplier;
|
||||
|
||||
class Suppliers extends Persons
|
||||
{
|
||||
private Supplier $supplier;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('suppliers');
|
||||
|
||||
$this->supplier = model(Supplier::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['table_headers'] = get_suppliers_manage_table_headers();
|
||||
|
||||
echo view('people/manage', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets one row for a supplier manage table. This is called using AJAX to update one row.
|
||||
* @param $row_id
|
||||
* @return void
|
||||
*/
|
||||
public function getRow($row_id): void
|
||||
{
|
||||
$data_row = get_supplier_data_row($this->supplier->get_info($row_id));
|
||||
$data_row['category'] = $this->supplier->get_category_name($data_row['category']);
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Supplier table data rows. This will be called with AJAX.
|
||||
* @return void
|
||||
**/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$suppliers = $this->supplier->search($search, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->supplier->get_found_rows($search);
|
||||
|
||||
$data_rows = [];
|
||||
|
||||
foreach($suppliers->getResult() as $supplier)
|
||||
{
|
||||
$row = get_supplier_data_row($supplier);
|
||||
$row['category'] = $this->supplier->get_category_name($row['category']);
|
||||
$data_rows[] = $row;
|
||||
}
|
||||
|
||||
echo json_encode (['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives search suggestions based on what is being searched for
|
||||
**/
|
||||
public function getSuggest(): void
|
||||
{
|
||||
$suggestions = $this->supplier->get_search_suggestions($this->request->getGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), true);
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function suggest_search(): void
|
||||
{
|
||||
$suggestions = $this->supplier->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS), false);
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the supplier edit form
|
||||
*
|
||||
* @param int $supplier_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $supplier_id = NEW_ENTRY): void
|
||||
{
|
||||
$info = $this->supplier->get_info($supplier_id);
|
||||
foreach(get_object_vars($info) as $property => $value)
|
||||
{
|
||||
$info->$property = $value;
|
||||
}
|
||||
$data['person_info'] = $info;
|
||||
$data['categories'] = $this->supplier->get_categories();
|
||||
|
||||
echo view("suppliers/form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts/updates a supplier
|
||||
*
|
||||
* @param int $supplier_id
|
||||
* @return void
|
||||
*/
|
||||
public function postSave(int $supplier_id = NEW_ENTRY): void
|
||||
{
|
||||
$first_name = $this->request->getPost('first_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS); //TODO: Duplicate code
|
||||
$last_name = $this->request->getPost('last_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$email = strtolower($this->request->getPost('email', FILTER_SANITIZE_EMAIL));
|
||||
|
||||
// format first and last name properly
|
||||
$first_name = $this->nameize($first_name);
|
||||
$last_name = $this->nameize($last_name);
|
||||
|
||||
$person_data = [
|
||||
'first_name' => $first_name,
|
||||
'last_name' => $last_name,
|
||||
'gender' => $this->request->getPost('gender'),
|
||||
'email' => $email,
|
||||
'phone_number' => $this->request->getPost('phone_number', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'address_1' => $this->request->getPost('address_1', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'address_2' => $this->request->getPost('address_2', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'city' => $this->request->getPost('city', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'state' => $this->request->getPost('state', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'zip' => $this->request->getPost('zip', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'country' => $this->request->getPost('country', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'comments' => $this->request->getPost('comments', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
|
||||
];
|
||||
|
||||
$supplier_data = [
|
||||
'company_name' => $this->request->getPost('company_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'agency_name' => $this->request->getPost('agency_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'category' => $this->request->getPost('category', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'account_number' => $this->request->getPost('account_number') == '' ? null : $this->request->getPost('account_number', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'tax_id' => $this->request->getPost('tax_id', FILTER_SANITIZE_NUMBER_INT)
|
||||
];
|
||||
|
||||
if($this->supplier->save_supplier($person_data, $supplier_data, $supplier_id))
|
||||
{
|
||||
//New supplier
|
||||
if($supplier_id == NEW_ENTRY)
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Suppliers.successful_adding') . ' ' . $supplier_data['company_name'],
|
||||
'id' => $supplier_data['person_id']
|
||||
]);
|
||||
}
|
||||
else //Existing supplier
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Suppliers.successful_updating') . ' ' . $supplier_data['company_name'],
|
||||
'id' => $supplier_id]);
|
||||
}
|
||||
}
|
||||
else//failure
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Suppliers.error_adding_updating') . ' ' . $supplier_data['company_name'],
|
||||
'id' => NEW_ENTRY
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This deletes suppliers from the suppliers table
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$suppliers_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
if($this->supplier->delete_list($suppliers_to_delete))
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Suppliers.successful_deleted') . ' ' . count($suppliers_to_delete) . ' ' . lang('Suppliers.one_or_multiple')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Suppliers.cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
140
app/Controllers/Tax_categories.php
Normal file
140
app/Controllers/Tax_categories.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Tax_category;
|
||||
|
||||
/**
|
||||
* @property tax_category tax_category
|
||||
*/
|
||||
class Tax_categories extends Secure_Controller
|
||||
{
|
||||
private Tax_category $tax_category;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('tax_categories');
|
||||
|
||||
$this->tax_category = model(Tax_category::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['tax_categories_table_headers'] = get_tax_categories_table_headers();
|
||||
|
||||
echo view('taxes/tax_categories', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns tax_category table data rows. This will be called with AJAX.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$tax_categories = $this->tax_category->search($search, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->tax_category->get_found_rows($search);
|
||||
|
||||
$data_rows = [];
|
||||
foreach($tax_categories->getResult() as $tax_category)
|
||||
{
|
||||
$data_rows[] = get_tax_categories_data_row($tax_category);
|
||||
}
|
||||
|
||||
echo json_encode (['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $row_id
|
||||
* @return void
|
||||
*/
|
||||
public function getRow($row_id): void
|
||||
{
|
||||
$data_row = get_tax_categories_data_row($this->tax_category->get_info($row_id));
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $tax_category_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $tax_category_id = NEW_ENTRY): void
|
||||
{
|
||||
$data['tax_category_info'] = $this->tax_category->get_info($tax_category_id);
|
||||
|
||||
echo view("taxes/tax_category_form", $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $tax_category_id
|
||||
* @return void
|
||||
*/
|
||||
public function postSave(int $tax_category_id = NEW_ENTRY): void
|
||||
{
|
||||
$tax_category_data = [
|
||||
'tax_category' => $this->request->getPost('tax_category', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'tax_category_code' => $this->request->getPost('tax_category_code', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'tax_group_sequence' => $this->request->getPost('tax_group_sequence', FILTER_SANITIZE_NUMBER_INT)
|
||||
];
|
||||
|
||||
if($this->tax_category->save_value($tax_category_data, $tax_category_id))
|
||||
{
|
||||
// New tax_category_id
|
||||
if($tax_category_id == NEW_ENTRY)
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Tax_categories.successful_adding'),
|
||||
'id' => $tax_category_data['tax_category_id']
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Tax_categories.successful_updating'),
|
||||
'id' => $tax_category_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Tax_categories.error_adding_updating') . ' ' . $tax_category_data['tax_category'],
|
||||
'id' => NEW_ENTRY
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$tax_categories_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
if($this->tax_category->delete_list($tax_categories_to_delete))
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Tax_categories.successful_deleted') . ' ' . count($tax_categories_to_delete) . ' ' . lang('Tax_categories.one_or_multiple')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Tax_categories.cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
151
app/Controllers/Tax_codes.php
Normal file
151
app/Controllers/Tax_codes.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Tax_code;
|
||||
|
||||
/**
|
||||
* @property tax_code tax_code
|
||||
*/
|
||||
class Tax_codes extends Secure_Controller
|
||||
{
|
||||
private Tax_code $tax_code;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('tax_codes');
|
||||
|
||||
$this->tax_code = model(Tax_code::class);
|
||||
helper('tax_helper');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
echo view('taxes/tax_codes', $this->get_data());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function get_data(): array
|
||||
{
|
||||
|
||||
$data['table_headers'] = get_tax_code_table_headers();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns tax_category table data rows. This will be called with AJAX.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$tax_codes = $this->tax_code->search($search, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->tax_code->get_found_rows($search);
|
||||
|
||||
$data_rows = [];
|
||||
|
||||
foreach($tax_codes->getResult() as $tax_code)
|
||||
{
|
||||
$data_rows[] = get_tax_code_data_row($tax_code);
|
||||
}
|
||||
|
||||
echo json_encode (['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $row_id
|
||||
* @return void
|
||||
*/
|
||||
public function getRow(int $row_id): void
|
||||
{
|
||||
$data_row = get_tax_code_data_row($this->tax_code->get_info($row_id));
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $tax_code_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $tax_code_id = NEW_ENTRY): void
|
||||
{
|
||||
$data['tax_code_info'] = $this->tax_code->get_info($tax_code_id);
|
||||
|
||||
echo view("taxes/tax_code_form", $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $tax_code_id
|
||||
* @return void
|
||||
*/
|
||||
public function postSave(int $tax_code_id = NEW_ENTRY): void
|
||||
{
|
||||
$tax_code_data = [
|
||||
'tax_code' => $this->request->getPost('tax_code', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'tax_code_name' => $this->request->getPost('tax_code_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'city' => $this->request->getPost('city', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'state' => $this->request->getPost('state', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
|
||||
];
|
||||
|
||||
if($this->tax_code->save($tax_code_data))
|
||||
{
|
||||
if($tax_code_id == NEW_ENTRY)
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Tax_codes.successful_adding'),
|
||||
'id' => $tax_code_data['tax_code_id']
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Tax_codes.successful_updating'),
|
||||
'id' => $tax_code_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Tax_codes.error_adding_updating') . ' ' . $tax_code_data['tax_code_id'],
|
||||
'id' => NEW_ENTRY
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$tax_codes_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
if($this->tax_code->delete_list($tax_codes_to_delete))
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Tax_codes.successful_deleted') . ' ' . count($tax_codes_to_delete) . ' ' . lang('Tax_codes.one_or_multiple')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Tax_codes.cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
141
app/Controllers/Tax_jurisdictions.php
Normal file
141
app/Controllers/Tax_jurisdictions.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\Tax_jurisdiction;
|
||||
|
||||
/**
|
||||
* @property tax_jurisdiction tax_jurisdiction
|
||||
*/
|
||||
class Tax_jurisdictions extends Secure_Controller
|
||||
{
|
||||
private Tax_jurisdiction $tax_jurisdiction;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('tax_jurisdictions');
|
||||
|
||||
$this->tax_jurisdiction = model(Tax_jurisdiction::class);
|
||||
|
||||
helper('tax_helper');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['table_headers'] = get_tax_jurisdictions_table_headers();
|
||||
|
||||
echo view('taxes/tax_jurisdictions', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns tax_category table data rows. This will be called with AJAX.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$tax_jurisdictions = $this->tax_jurisdiction->search($search, $limit, $offset, $sort, $order);
|
||||
$total_rows = $this->tax_jurisdiction->get_found_rows($search);
|
||||
|
||||
$data_rows = [];
|
||||
foreach($tax_jurisdictions->getResult() as $tax_jurisdiction)
|
||||
{
|
||||
$data_rows[] = get_tax_jurisdictions_data_row($tax_jurisdiction);
|
||||
}
|
||||
|
||||
echo json_encode (['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $row_id
|
||||
* @return void
|
||||
*/
|
||||
public function getRow(int $row_id): void
|
||||
{
|
||||
$data_row = get_tax_jurisdictions_data_row($this->tax_jurisdiction->get_info($row_id));
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $tax_jurisdiction_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $tax_jurisdiction_id = NEW_ENTRY): void
|
||||
{
|
||||
$data['tax_jurisdiction_info'] = $this->tax_jurisdiction->get_info($tax_jurisdiction_id);
|
||||
|
||||
echo view("taxes/tax_jurisdiction_form", $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $jurisdiction_id
|
||||
* @return void
|
||||
*/
|
||||
public function postSave(int $jurisdiction_id = NEW_ENTRY): void
|
||||
{
|
||||
$tax_jurisdiction_data = [
|
||||
'jurisdiction_name' => $this->request->getPost('jurisdiction_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
|
||||
'reporting_authority' => $this->request->getPost('reporting_authority', FILTER_SANITIZE_FULL_SPECIAL_CHARS)
|
||||
];
|
||||
|
||||
if($this->tax_jurisdiction->save_value($tax_jurisdiction_data))
|
||||
{
|
||||
if($jurisdiction_id == NEW_ENTRY)
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Tax_jurisdictions.successful_adding'),
|
||||
'id' => $tax_jurisdiction_data['jurisdiction_id']
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Tax_jurisdictions.successful_updating'),
|
||||
'id' => $jurisdiction_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Tax_jurisdictions.error_adding_updating') . ' ' . $tax_jurisdiction_data['jurisdiction_name'],
|
||||
'id' => NEW_ENTRY
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$tax_jurisdictions_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
if($this->tax_jurisdiction->delete_list($tax_jurisdictions_to_delete))
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => true,
|
||||
'message' => lang('Tax_jurisdictions.successful_deleted') . ' ' . count($tax_jurisdictions_to_delete) . ' ' . lang('Tax_jurisdictions.one_or_multiple')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Tax_jurisdictions.cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
637
app/Controllers/Taxes.php
Normal file
637
app/Controllers/Taxes.php
Normal file
@@ -0,0 +1,637 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Libraries\Tax_lib;
|
||||
use App\Models\enums\Rounding_mode;
|
||||
use App\Models\Tax;
|
||||
use App\Models\Tax_category;
|
||||
use App\Models\Tax_code;
|
||||
use App\Models\Tax_jurisdiction;
|
||||
use Config\OSPOS;
|
||||
|
||||
class Taxes extends Secure_Controller
|
||||
{
|
||||
private array $config;
|
||||
private Tax_lib $tax_lib;
|
||||
private Tax $tax;
|
||||
private Tax_category $tax_category;
|
||||
private Tax_code $tax_code;
|
||||
private Tax_jurisdiction $tax_jurisdiction;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('taxes');
|
||||
|
||||
$this->tax = model(Tax::class);
|
||||
$this->tax_category = model(Tax_category::class);
|
||||
$this->tax_code = model(Tax_code::class);
|
||||
$this->tax_jurisdiction = model(Tax_jurisdiction::class);
|
||||
|
||||
$this->tax_lib = new Tax_lib();
|
||||
$this->config = config(OSPOS::class)->settings;
|
||||
|
||||
helper('tax_helper');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getIndex(): void
|
||||
{
|
||||
$data['tax_codes'] = $this->tax_code->get_all()->getResultArray();
|
||||
if (count($data['tax_codes']) == 0)
|
||||
{
|
||||
$data['tax_codes'] = $this->tax_code->get_empty_row();
|
||||
}
|
||||
|
||||
$data['tax_categories'] = $this->tax_category->get_all()->getResultArray();
|
||||
if (count($data['tax_categories']) == 0)
|
||||
{
|
||||
$data['tax_categories'] = $this->tax_category->get_empty_row();
|
||||
}
|
||||
|
||||
$data['tax_jurisdictions'] = $this->tax_jurisdiction->get_all()->getResultArray();
|
||||
if (count($data['tax_jurisdictions']) == 0)
|
||||
{
|
||||
$data['tax_jurisdictions'] = $this->tax_jurisdiction->get_empty_row();
|
||||
}
|
||||
|
||||
$data['tax_rate_table_headers'] = get_tax_rates_manage_table_headers();
|
||||
$data['tax_categories_table_headers'] = get_tax_categories_table_headers();
|
||||
$data['tax_types'] = $this->tax_lib->get_tax_types();
|
||||
|
||||
if($this->config['tax_included'])
|
||||
{
|
||||
$data['default_tax_type'] = Tax_lib::TAX_TYPE_INCLUDED;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['default_tax_type'] = Tax_lib::TAX_TYPE_EXCLUDED;
|
||||
}
|
||||
|
||||
$data['tax_type_options'] = $this->tax_lib->get_tax_type_options($data['default_tax_type']);
|
||||
|
||||
echo view('taxes/manage', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns tax_codes table data rows. This will be called with AJAX.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSearch(): void
|
||||
{
|
||||
$search = $this->request->getGet('search', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$limit = $this->request->getGet('limit', FILTER_SANITIZE_NUMBER_INT);
|
||||
$offset = $this->request->getGet('offset', FILTER_SANITIZE_NUMBER_INT);
|
||||
$sort = $this->request->getGet('sort', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$order = $this->request->getGet('order', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$tax_rates = $this->tax->search($search, $limit, $offset, $sort, $order);
|
||||
|
||||
$total_rows = $this->tax->get_found_rows($search);
|
||||
|
||||
$data_rows = [];
|
||||
foreach($tax_rates->getResult() as $tax_rate_row)
|
||||
{
|
||||
$data_rows[] = get_tax_rates_data_row($tax_rate_row);
|
||||
}
|
||||
|
||||
echo json_encode (['total' => $total_rows, 'rows' => $data_rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives search suggestions based on what is being searched for
|
||||
*/
|
||||
public function suggest_search(): void
|
||||
{
|
||||
$suggestions = $this->tax->get_search_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); //TODO: There is no get_search_suggestions function in the tax model
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides list of tax categories to select from
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function suggest_tax_categories(): void
|
||||
{
|
||||
$suggestions = $this->tax_category->get_tax_category_suggestions($this->request->getPost('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $row_id
|
||||
* @return void
|
||||
*/
|
||||
public function getRow(int $row_id): void
|
||||
{
|
||||
$data_row = get_tax_rates_data_row($this->tax->get_info($row_id));
|
||||
|
||||
echo json_encode($data_row);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $tax_code
|
||||
* @return void
|
||||
*/
|
||||
public function getView_tax_codes(int $tax_code = NEW_ENTRY): void
|
||||
{
|
||||
$tax_code_info = $this->tax->get_info($tax_code);
|
||||
|
||||
$default_tax_category_id = 1; // Tax category id is always the default tax category //TODO: Replace 1 with constant
|
||||
$default_tax_category = $this->tax->get_tax_category($default_tax_category_id); //TODO: this variable is never used in the code.
|
||||
|
||||
$tax_rate_info = $this->tax->get_rate_info($tax_code, $default_tax_category_id);
|
||||
|
||||
if($this->config['tax_included'])
|
||||
{
|
||||
$data['default_tax_type'] = Tax_lib::TAX_TYPE_INCLUDED;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['default_tax_type'] = Tax_lib::TAX_TYPE_EXCLUDED;
|
||||
}
|
||||
|
||||
$data['rounding_options'] = rounding_mode::get_rounding_options();
|
||||
$data['html_rounding_options'] = $this->get_html_rounding_options();
|
||||
|
||||
if($tax_code == NEW_ENTRY)
|
||||
{//TODO: Duplicated code
|
||||
$data['tax_code'] = '';
|
||||
$data['tax_code_name'] = '';
|
||||
$data['tax_code_type'] = '0';
|
||||
$data['city'] = '';
|
||||
$data['state'] = '';
|
||||
$data['tax_rate'] = '0.0000';
|
||||
$data['rate_tax_code'] = '';
|
||||
$data['rate_tax_category_id'] = 1;
|
||||
$data['tax_category'] = '';
|
||||
$data['add_tax_category'] = '';
|
||||
$data['rounding_code'] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['tax_code'] = $tax_code;
|
||||
$data['tax_code_name'] = $tax_code_info->tax_code_name;
|
||||
$data['tax_code_type'] = $tax_code_info->tax_code_type;
|
||||
$data['city'] = $tax_code_info->city;
|
||||
$data['state'] = $tax_code_info->state;
|
||||
$data['rate_tax_code'] = $tax_code_info->rate_tax_code;
|
||||
$data['rate_tax_category_id'] = $tax_code_info->rate_tax_category_id;
|
||||
$data['tax_category'] = $tax_code_info->tax_category;
|
||||
$data['add_tax_category'] = '';
|
||||
$data['tax_rate'] = $tax_rate_info->tax_rate;
|
||||
$data['rounding_code'] = $tax_rate_info->rounding_code;
|
||||
}
|
||||
|
||||
$tax_rates = [];
|
||||
foreach($this->tax->get_tax_code_rate_exceptions($tax_code) as $tax_code_rate) //TODO: get_tax_code_rate_exceptions doesn't exist. This was deleted by @steveireland in https://github.com/opensourcepos/opensourcepos/commit/32204698379c230f2a6756655f40334308023de9#diff-e746bab6720cf5dbf855de6cda68f7aca9ecea7ddd5a39bb852e9b9047a7a838L435 but it's unclear if that was on purpose or accidental.
|
||||
{
|
||||
$tax_rate_row = [];
|
||||
$tax_rate_row['rate_tax_category_id'] = $tax_code_rate['rate_tax_category_id'];
|
||||
$tax_rate_row['tax_category'] = $tax_code_rate['tax_category'];
|
||||
$tax_rate_row['tax_rate'] = $tax_code_rate['tax_rate'];
|
||||
$tax_rate_row['rounding_code'] = $tax_code_rate['rounding_code'];
|
||||
|
||||
$tax_rates[] = $tax_rate_row;
|
||||
}
|
||||
|
||||
$data['tax_rates'] = $tax_rates;
|
||||
|
||||
echo view('taxes/tax_code_form', $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $tax_rate_id
|
||||
* @return void
|
||||
*/
|
||||
public function getView(int $tax_rate_id = NEW_ENTRY): void
|
||||
{
|
||||
$tax_rate_info = $this->tax->get_info($tax_rate_id);
|
||||
|
||||
$data['tax_rate_id'] = $tax_rate_id;
|
||||
$data['rounding_options'] = rounding_mode::get_rounding_options();
|
||||
|
||||
$data['tax_code_options'] = $this->tax_lib->get_tax_code_options();
|
||||
$data['tax_category_options'] = $this->tax_lib->get_tax_category_options();
|
||||
$data['tax_jurisdiction_options'] = $this->tax_lib->get_tax_jurisdiction_options();
|
||||
|
||||
if($tax_rate_id == NEW_ENTRY)
|
||||
{
|
||||
$data['rate_tax_code_id'] = $this->config['default_tax_code'];
|
||||
$data['rate_tax_category_id'] = $this->config['default_tax_category'];
|
||||
$data['rate_jurisdiction_id'] = $this->config['default_tax_jurisdiction'];
|
||||
$data['tax_rounding_code'] = rounding_mode::HALF_UP;
|
||||
$data['tax_rate'] = '0.0000';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['rate_tax_code_id'] = $tax_rate_info->rate_tax_code_id;
|
||||
$data['rate_tax_code'] = $tax_rate_info->tax_code;
|
||||
$data['rate_tax_category_id'] = $tax_rate_info->rate_tax_category_id;
|
||||
$data['rate_jurisdiction_id'] = $tax_rate_info->rate_jurisdiction_id;
|
||||
$data['tax_rounding_code'] = $tax_rate_info->tax_rounding_code;
|
||||
$data['tax_rate'] = $tax_rate_info->tax_rate;
|
||||
}
|
||||
|
||||
echo view('taxes/tax_rates_form', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $tax_code
|
||||
* @return void
|
||||
*/
|
||||
public function getView_tax_categories(int $tax_code = NEW_ENTRY): void //TODO: This appears to be called no where in the code.
|
||||
{
|
||||
$tax_code_info = $this->tax->get_info($tax_code); //TODO: Duplicated Code
|
||||
|
||||
$default_tax_category_id = 1; // Tax category id is always the default tax category //TODO: replace with a constant.
|
||||
$default_tax_category = $this->tax->get_tax_category($default_tax_category_id);
|
||||
|
||||
$tax_rate_info = $this->tax->get_rate_info($tax_code, $default_tax_category_id);
|
||||
|
||||
$data['rounding_options'] = rounding_mode::get_rounding_options();
|
||||
$data['html_rounding_options'] = $this->get_html_rounding_options();
|
||||
|
||||
if($this->config['tax_included'])
|
||||
{
|
||||
$data['default_tax_type'] = Tax_lib::TAX_TYPE_INCLUDED;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['default_tax_type'] = Tax_lib::TAX_TYPE_EXCLUDED;
|
||||
}
|
||||
|
||||
if($tax_code == NEW_ENTRY)
|
||||
{
|
||||
$data['tax_code'] = '';
|
||||
$data['tax_code_name'] = '';
|
||||
$data['tax_code_type'] = '0';
|
||||
$data['city'] = '';
|
||||
$data['state'] = '';
|
||||
$data['tax_rate'] = '0.0000';
|
||||
$data['rate_tax_code'] = '';
|
||||
$data['rate_tax_category_id'] = 1;
|
||||
$data['tax_category'] = '';
|
||||
$data['add_tax_category'] = '';
|
||||
$data['rounding_code'] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['tax_code'] = $tax_code;
|
||||
$data['tax_code_name'] = $tax_code_info->tax_code_name;
|
||||
$data['tax_code_type'] = $tax_code_info->tax_code_type;
|
||||
$data['city'] = $tax_code_info->city;
|
||||
$data['state'] = $tax_code_info->state;
|
||||
$data['rate_tax_code'] = $tax_code_info->rate_tax_code;
|
||||
$data['rate_tax_category_id'] = $tax_code_info->rate_tax_category_id;
|
||||
$data['tax_category'] = $tax_code_info->tax_category;
|
||||
$data['add_tax_category'] = '';
|
||||
$data['tax_rate'] = $tax_rate_info->tax_rate;
|
||||
$data['rounding_code'] = $tax_rate_info->rounding_code;
|
||||
}
|
||||
|
||||
$tax_rates = [];
|
||||
foreach($this->tax->get_tax_code_rate_exceptions($tax_code) as $tax_code_rate) //TODO: get_tax_code_rate_exceptions doesn't exist in the tax model
|
||||
{
|
||||
$tax_rate_row = [];
|
||||
$tax_rate_row['rate_tax_category_id'] = $tax_code_rate['rate_tax_category_id'];
|
||||
$tax_rate_row['tax_category'] = $tax_code_rate['tax_category'];
|
||||
$tax_rate_row['tax_rate'] = $tax_code_rate['tax_rate'];
|
||||
$tax_rate_row['rounding_code'] = $tax_code_rate['rounding_code'];
|
||||
|
||||
$tax_rates[] = $tax_rate_row;
|
||||
}
|
||||
|
||||
$data['tax_rates'] = $tax_rates;
|
||||
|
||||
echo view('taxes/tax_category_form', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $tax_code
|
||||
* @return void
|
||||
*/
|
||||
public function getView_tax_jurisdictions(int $tax_code = NEW_ENTRY): void //TODO: This appears to be called no where in the code.
|
||||
{
|
||||
$tax_code_info = $this->tax->get_info($tax_code); //TODO: Duplicated code
|
||||
|
||||
$default_tax_category_id = 1; // Tax category id is always the default tax category
|
||||
$default_tax_category = $this->tax->get_tax_category($default_tax_category_id); //TODO: This variable is not used anywhere in the code
|
||||
|
||||
$tax_rate_info = $this->tax->get_rate_info($tax_code, $default_tax_category_id);
|
||||
|
||||
$data['rounding_options'] = rounding_mode::get_rounding_options();
|
||||
$data['html_rounding_options'] = $this->get_html_rounding_options();
|
||||
|
||||
if($this->config['tax_included'])
|
||||
{
|
||||
$data['default_tax_type'] = Tax_lib::TAX_TYPE_INCLUDED;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['default_tax_type'] = Tax_lib::TAX_TYPE_EXCLUDED;
|
||||
}
|
||||
|
||||
if($tax_code == NEW_ENTRY)
|
||||
{
|
||||
$data['tax_code'] = '';
|
||||
$data['tax_code_name'] = '';
|
||||
$data['tax_code_type'] = '0';
|
||||
$data['city'] = '';
|
||||
$data['state'] = '';
|
||||
$data['tax_rate'] = '0.0000';
|
||||
$data['rate_tax_code'] = '';
|
||||
$data['rate_tax_category_id'] = 1;
|
||||
$data['tax_category'] = '';
|
||||
$data['add_tax_category'] = '';
|
||||
$data['rounding_code'] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['tax_code'] = $tax_code;
|
||||
$data['tax_code_name'] = $tax_code_info->tax_code_name;
|
||||
$data['tax_code_type'] = $tax_code_info->tax_code_type;
|
||||
$data['city'] = $tax_code_info->city;
|
||||
$data['state'] = $tax_code_info->state;
|
||||
$data['rate_tax_code'] = $tax_code_info->rate_tax_code;
|
||||
$data['rate_tax_category_id'] = $tax_code_info->rate_tax_category_id;
|
||||
$data['tax_category'] = $tax_code_info->tax_category;
|
||||
$data['add_tax_category'] = '';
|
||||
$data['tax_rate'] = $tax_rate_info->tax_rate;
|
||||
$data['rounding_code'] = $tax_rate_info->rounding_code;
|
||||
}
|
||||
|
||||
$tax_rates = [];
|
||||
foreach($this->tax->get_tax_code_rate_exceptions($tax_code) as $tax_code_rate) //TODO: get_tax_code_rate_exceptions doesn't exist in the tax model
|
||||
{
|
||||
$tax_rate_row = [];
|
||||
$tax_rate_row['rate_tax_category_id'] = $tax_code_rate['rate_tax_category_id'];
|
||||
$tax_rate_row['tax_category'] = $tax_code_rate['tax_category'];
|
||||
$tax_rate_row['tax_rate'] = $tax_code_rate['tax_rate'];
|
||||
$tax_rate_row['rounding_code'] = $tax_code_rate['rounding_code'];
|
||||
|
||||
$tax_rates[] = $tax_rate_row;
|
||||
}
|
||||
|
||||
$data['tax_rates'] = $tax_rates;
|
||||
|
||||
echo view('taxes/tax_jurisdiction_form', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function get_html_rounding_options(): string
|
||||
{
|
||||
return rounding_mode::get_html_rounding_options();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $tax_rate_id
|
||||
* @return void
|
||||
*/
|
||||
public function postSave(int $tax_rate_id = NEW_ENTRY): void
|
||||
{
|
||||
$raw_tax_rate = prepare_decimal($this->request->getPost('tax_rate'));
|
||||
|
||||
$tax_category_id = $this->request->getPost('rate_tax_category_id', FILTER_SANITIZE_NUMBER_INT);
|
||||
$tax_rate = parse_tax(filter_var($raw_tax_rate, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
|
||||
|
||||
if ($tax_rate == 0) //TODO: Replace 0 with constant?
|
||||
{
|
||||
$tax_category_info = $this->tax_category->get_info($tax_category_id); //TODO: this variable is not used anywhere in the code
|
||||
}
|
||||
|
||||
$tax_rate_data = [
|
||||
'rate_tax_code_id' => $this->request->getPost('rate_tax_code_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'rate_tax_category_id' => $this->request->getPost('rate_tax_category_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'rate_jurisdiction_id' => $this->request->getPost('rate_jurisdiction_id', FILTER_SANITIZE_NUMBER_INT),
|
||||
'tax_rate' => $tax_rate,
|
||||
'tax_rounding_code' => $this->request->getPost('tax_rounding_code', FILTER_SANITIZE_NUMBER_INT)
|
||||
];
|
||||
|
||||
if($this->tax->save_value($tax_rate_data, $tax_rate_id))
|
||||
{
|
||||
if($tax_rate_id == NEW_ENTRY)
|
||||
{//TODO: this needs to be replaced with ternary notation
|
||||
echo json_encode (['success' => true, 'message' => lang('Taxes.tax_rate_successfully_added')]);
|
||||
}
|
||||
else //Existing tax_code
|
||||
{
|
||||
echo json_encode (['success' => true, 'message' => lang('Taxes.tax_rate_successful_updated')]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Taxes.tax_rate_error_adding_updating')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function postDelete(): void
|
||||
{
|
||||
$tax_codes_to_delete = $this->request->getPost('ids', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
if($this->tax->delete_list($tax_codes_to_delete)) //TODO: this needs to be replaced with ternary notation
|
||||
{
|
||||
echo json_encode (['success' => true, 'message' => lang('Taxes.tax_code_successful_deleted')]);
|
||||
} else
|
||||
{
|
||||
echo json_encode (['success' => false, 'message' => lang('Taxes.tax_code_cannot_be_deleted')]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get search suggestions for tax codes. Used in app/Views/customers/form.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function getSuggestTaxCodes(): void
|
||||
{
|
||||
$suggestions = $this->tax_code->get_tax_codes_search_suggestions($this->request->getPostGet('term', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
|
||||
|
||||
echo json_encode($suggestions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves Tax Codes. Used in app/Views/taxes/tax_codes.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function save_tax_codes(): void
|
||||
{
|
||||
$tax_code_id = $this->request->getPost('tax_code_id', FILTER_SANITIZE_NUMBER_INT);
|
||||
$tax_code = $this->request->getPost('tax_code', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$tax_code_name = $this->request->getPost('tax_code_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$city = $this->request->getPost('city', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$state = $this->request->getPost('state', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
$array_save = []; //TODO: the naming of this variable is not good.
|
||||
foreach($tax_code_id as $key=>$val)
|
||||
{
|
||||
$array_save[] = [
|
||||
'tax_code_id'=>$val,
|
||||
'tax_code'=>$tax_code[$key],
|
||||
'tax_code_name'=>$tax_code_name[$key],
|
||||
'city'=>$city[$key],
|
||||
'state'=>$state[$key]
|
||||
];
|
||||
}
|
||||
|
||||
$success = $this->tax_code->save_tax_codes($array_save);
|
||||
|
||||
echo json_encode ([
|
||||
'success' => $success,
|
||||
'message' => lang('Taxes.tax_codes_saved_' . ($success ? '' : 'un') . 'successfully')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves given tax jurisdiction. Used in app/Views/taxes/tax_jurisdictions.php.
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function save_tax_jurisdictions(): void
|
||||
{
|
||||
$jurisdiction_id = $this->request->getPost('jurisdiction_id', FILTER_SANITIZE_NUMBER_INT);
|
||||
$jurisdiction_name = $this->request->getPost('jurisdiction_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$tax_group = $this->request->getPost('tax_group', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$tax_type = $this->request->getPost('tax_type', FILTER_SANITIZE_NUMBER_INT);
|
||||
$reporting_authority = $this->request->getPost('reporting_authority', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$tax_group_sequence = $this->request->getPost('tax_group_sequence', FILTER_SANITIZE_NUMBER_INT);
|
||||
$cascade_sequence = $this->request->getPost('cascade_sequence', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
$array_save = [];
|
||||
$unique_tax_groups = [];
|
||||
|
||||
foreach($jurisdiction_id as $key => $val)
|
||||
{
|
||||
$array_save[] = [
|
||||
'jurisdiction_id'=>$val,
|
||||
'jurisdiction_name'=>$jurisdiction_name[$key],
|
||||
'tax_group'=>$tax_group[$key],
|
||||
'tax_type'=>$tax_type[$key],
|
||||
'reporting_authority'=>$reporting_authority[$key],
|
||||
'tax_group_sequence'=>$tax_group_sequence[$key],
|
||||
'cascade_sequence'=>$cascade_sequence[$key]
|
||||
];
|
||||
|
||||
if (in_array($tax_group[$key], $unique_tax_groups)) //TODO: This can be replaced with `in_array($tax_group[$key], $unique_tax_groups)`
|
||||
{
|
||||
echo json_encode ([
|
||||
'success' => false,
|
||||
'message' => lang('Taxes.tax_group_not_unique', [$tax_group[$key]])
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$unique_tax_groups[] = $tax_group[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$success = $this->tax_jurisdiction->save_jurisdictions($array_save);
|
||||
|
||||
echo json_encode ([
|
||||
'success' => $success,
|
||||
'message' => lang('Taxes.tax_jurisdictions_saved_' . ($success ? '' : 'un') . 'successfully')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves tax categories. Used in app/Views/taxes/tax_categories.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function save_tax_categories(): void
|
||||
{
|
||||
$tax_category_id = $this->request->getPost('tax_category_id', FILTER_SANITIZE_NUMBER_INT);
|
||||
$tax_category = $this->request->getPost('tax_category', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$tax_group_sequence = $this->request->getPost('tax_group_sequence', FILTER_SANITIZE_NUMBER_INT);
|
||||
|
||||
$array_save= [];
|
||||
|
||||
foreach($tax_category_id as $key => $val)
|
||||
{
|
||||
$array_save[] = [
|
||||
'tax_category_id'=>$val,
|
||||
'tax_category'=>$tax_category[$key],
|
||||
'tax_group_sequence'=>$tax_group_sequence[$key]
|
||||
];
|
||||
}
|
||||
|
||||
$success = $this->tax_category->save_categories($array_save);
|
||||
|
||||
echo json_encode ([
|
||||
'success' => $success,
|
||||
'message' => lang('Taxes.tax_categories_saved_' . ($success ? '' : 'un') . 'successfully')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets tax codes partial view. Used in app/Views/taxes/tax_codes.php.
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function ajax_tax_codes(): void
|
||||
{
|
||||
$tax_codes = $this->tax_code->get_all()->getResultArray();
|
||||
|
||||
echo view('partial/tax_codes', ['tax_codes' => $tax_codes]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets current tax categories. Used in app/Views/taxes/tax_categories.php
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function ajax_tax_categories(): void
|
||||
{
|
||||
$tax_categories = $this->tax_category->get_all()->getResultArray();
|
||||
|
||||
echo view('partial/tax_categories', ['tax_categories' => $tax_categories]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tax jurisdiction partial view. Used in app/Views/taxes/tax_jurisdictions.php.
|
||||
*
|
||||
* @return void
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function ajax_tax_jurisdictions(): void
|
||||
{
|
||||
$tax_jurisdictions = $this->tax_jurisdiction->get_all()->getResultArray();
|
||||
|
||||
if($this->config['tax_included']) //TODO: ternary notation
|
||||
{
|
||||
$default_tax_type = Tax_lib::TAX_TYPE_INCLUDED;
|
||||
}
|
||||
else
|
||||
{
|
||||
$default_tax_type = Tax_lib::TAX_TYPE_EXCLUDED;
|
||||
}
|
||||
|
||||
$tax_types = $this->tax_lib->get_tax_types();
|
||||
|
||||
echo view('partial/tax_jurisdictions', [
|
||||
'tax_jurisdictions' => $tax_jurisdictions,
|
||||
'tax_types' => $tax_types,
|
||||
'default_tax_type' => $default_tax_type
|
||||
]);
|
||||
}
|
||||
}
|
||||
11
app/Controllers/index.html
Normal file
11
app/Controllers/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
30
app/Database/Migrations/20170501150000_upgrade_to_3_1_1.php
Normal file
30
app/Database/Migrations/20170501150000_upgrade_to_3_1_1.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class Migration_Upgrade_To_3_1_1 extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a migration step.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
helper('migration');
|
||||
execute_script(APPPATH . 'Database/Migrations/sqlscripts/3.0.2_to_3.1.1.sql');
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert a migration step.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
430
app/Database/Migrations/20170502221506_sales_tax_data.php
Normal file
430
app/Database/Migrations/20170502221506_sales_tax_data.php
Normal file
@@ -0,0 +1,430 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use App\Libraries\Tax_lib;
|
||||
use App\Models\Appconfig;
|
||||
use CodeIgniter\Database\Migration;
|
||||
use CodeIgniter\Database\ResultInterface;
|
||||
|
||||
/**
|
||||
* @property tax_lib tax_lib
|
||||
* @property appconfig appconfig
|
||||
*/
|
||||
class Migration_Sales_Tax_Data extends Migration
|
||||
{
|
||||
public const ROUND_UP = 5; //TODO: These need to be moved to constants.php
|
||||
public const ROUND_DOWN = 6;
|
||||
public const HALF_FIVE = 7;
|
||||
public const YES = '1';
|
||||
public const VAT_TAX = '0';
|
||||
public const SALES_TAX = '1';
|
||||
private Appconfig $appconfig;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->appconfig = model(Appconfig::class);
|
||||
}
|
||||
//TODO: we need to figure out why we get a server error when uncommented portions of this migration run
|
||||
|
||||
/**
|
||||
* Perform a migration step.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$number_of_unmigrated = $this->get_count_of_unmigrated();
|
||||
error_log("Migrating sales tax history. The number of sales that will be migrated is $number_of_unmigrated");
|
||||
|
||||
if($number_of_unmigrated > 0)
|
||||
{
|
||||
$unmigrated_invoices = $this->get_unmigrated($number_of_unmigrated)->getResultArray();
|
||||
|
||||
foreach($unmigrated_invoices as $key => $unmigrated_invoice)
|
||||
{
|
||||
$this->upgrade_tax_history_for_sale($unmigrated_invoice['sale_id']);
|
||||
}
|
||||
}
|
||||
|
||||
error_log('Migrating sales tax history. The number of sales that will be migrated is finished.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert a migration step.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $sale_id
|
||||
* @return void
|
||||
*/
|
||||
private function upgrade_tax_history_for_sale(int $sale_id): void
|
||||
{
|
||||
$tax_decimals = $this->appconfig->get_value('tax_decimals', 2);
|
||||
$tax_included = $this->appconfig->get_value('tax_included', Migration_Sales_Tax_Data::YES) == Migration_Sales_Tax_Data::YES;
|
||||
$customer_sales_tax_support = false;
|
||||
|
||||
if($tax_included) //TODO: Convert to ternary notation.
|
||||
{
|
||||
$tax_type = Migration_Sales_Tax_Data::VAT_TAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
$tax_type = Migration_Sales_Tax_Data::SALES_TAX;
|
||||
}
|
||||
|
||||
$sales_taxes = [];
|
||||
$tax_group_sequence = 0;
|
||||
$items = $this->get_sale_items_for_migration($sale_id)->getResultArray();
|
||||
|
||||
foreach($items as $item)
|
||||
{
|
||||
// This computes tax for each line item and adds it to the tax type total
|
||||
$tax_group = (float)$item['percent'] . '% ' . $item['name'];
|
||||
$tax_basis = $this->get_item_total($item['quantity_purchased'], $item['item_unit_price'], $item['discount_percent'], true);
|
||||
|
||||
$item_tax_amount = $tax_included
|
||||
? $this->get_item_tax($item['quantity_purchased'], $item['item_unit_price'], $item['discount_percent'], $item['percent'])
|
||||
: $this->get_sales_tax_for_amount($tax_basis, $item['percent'], PHP_ROUND_HALF_UP, $tax_decimals);
|
||||
|
||||
$this->update_sales_items_taxes_amount($sale_id, $item['line'], $item['name'], $item['percent'], $tax_type, $item_tax_amount);
|
||||
$this->update_sales_taxes($sales_taxes, $tax_type, $tax_group, $item['percent'], $tax_basis, $item_tax_amount, $tax_group_sequence, PHP_ROUND_HALF_UP, $sale_id, $item['name']);
|
||||
$tax_group_sequence++;
|
||||
}
|
||||
//Not sure when this would ever kick in, but this is technically the correct logic.
|
||||
if($customer_sales_tax_support) //TODO: This will always evaluate to false
|
||||
{
|
||||
$this->apply_invoice_taxing($sales_taxes);
|
||||
}
|
||||
|
||||
$this->round_sales_taxes($sales_taxes);
|
||||
$this->save_sales_tax($sales_taxes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $block_count
|
||||
* @return ResultInterface
|
||||
*/
|
||||
private function get_unmigrated(int $block_count): ResultInterface
|
||||
{
|
||||
$builder = $this->db->table('sales_items_taxes as SIT');
|
||||
$builder->select('SIT.sale_id');
|
||||
$builder->select('ST.sale_id as sales_taxes_sale_id');
|
||||
$builder->join('sales_taxes as ST','SIT.sale_id = ST.sale_id', 'left');
|
||||
$builder->where('ST.sale_id', null);
|
||||
$builder->groupBy('SIT.sale_id');
|
||||
$builder->groupBy('ST.sale_id');
|
||||
$builder->orderBy('SIT.sale_id');
|
||||
$builder->limit($block_count);
|
||||
|
||||
return $builder->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $sale_id
|
||||
* @return ResultInterface
|
||||
*/
|
||||
private function get_sale_items_for_migration(int $sale_id): ResultInterface
|
||||
{
|
||||
$builder = $this->db->table('sales_items as sales_items');
|
||||
$builder->select('sales_items.sale_id as sale_id');
|
||||
$builder->select('sales_items.line as line');
|
||||
$builder->select('item_unit_price');
|
||||
$builder->select('discount_percent');
|
||||
$builder->select('quantity_purchased');
|
||||
$builder->select('percent');
|
||||
$builder->select('name');
|
||||
$builder->join('sales_items_taxes as sales_items_taxes', 'sales_items.sale_id = sales_items_taxes.sale_id and sales_items.line = sales_items_taxes.line');
|
||||
$builder->where('sales_items.sale_id', $sale_id);
|
||||
|
||||
return $builder->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
private function get_count_of_unmigrated(): int
|
||||
{
|
||||
$result = $this->db->query('SELECT COUNT(*) FROM(SELECT SIT.sale_id, ST.sale_id as sales_taxes_sale_id FROM '
|
||||
. $this->db->prefixTable('sales_items_taxes')
|
||||
. ' as SIT LEFT JOIN '
|
||||
. $this->db->prefixTable('sales_taxes')
|
||||
. ' as ST ON SIT.sale_id = ST.sale_id WHERE ST.sale_id is null GROUP BY SIT.sale_id, ST.sale_id'
|
||||
. ' ORDER BY SIT.sale_id) as US')->getResultArray();
|
||||
return $result[0]['COUNT(*)'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $sale_id
|
||||
* @param int $line
|
||||
* @param string $name
|
||||
* @param float $percent
|
||||
* @param int $tax_type
|
||||
* @param float $item_tax_amount
|
||||
* @return void
|
||||
*/
|
||||
private function update_sales_items_taxes_amount(int $sale_id, int $line, string $name, float $percent, int $tax_type, float $item_tax_amount): void
|
||||
{
|
||||
$builder = $this->db->table('sales_items_taxes');
|
||||
$builder->where('sale_id', $sale_id);
|
||||
$builder->where('line', $line);
|
||||
$builder->where('name', $name);
|
||||
$builder->where('percent', $percent);
|
||||
$builder->update(['tax_type' => $tax_type, 'item_tax_amount' => $item_tax_amount]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $sales_taxes
|
||||
* @return void
|
||||
*/
|
||||
private function save_sales_tax(array &$sales_taxes): void
|
||||
{
|
||||
$builder = $this->db->Table('sales_taxes');
|
||||
|
||||
foreach($sales_taxes as $line => $sales_tax)
|
||||
{
|
||||
$builder->insert($sales_tax);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $quantity
|
||||
* @param string $price
|
||||
* @param string $discount_percentage
|
||||
* @param bool $include_discount
|
||||
* @return string
|
||||
*/
|
||||
public function get_item_total(string $quantity, string $price, string $discount_percentage, bool $include_discount = false): string
|
||||
{
|
||||
$total = bcmul($quantity, $price);
|
||||
|
||||
if($include_discount)
|
||||
{
|
||||
$discount_amount = $this->get_item_discount($quantity, $price, $discount_percentage);
|
||||
return bcsub($total, $discount_amount);
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $quantity
|
||||
* @param string $price
|
||||
* @param string $discount
|
||||
* @return float
|
||||
*/
|
||||
public function get_item_discount(string $quantity, string $price, string $discount): float
|
||||
{
|
||||
$total = bcmul($quantity, $price);
|
||||
$discount_fraction = bcdiv($discount, 100);
|
||||
$discount = bcmul($total, $discount_fraction);
|
||||
|
||||
return round($discount, totals_decimals(), PHP_ROUND_HALF_UP); //TODO: I don't think this is currency safe. Round will cast it's first parameter to a float. It also returns a float.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $quantity
|
||||
* @param string $price
|
||||
* @param string $discount_percentage
|
||||
* @param string $tax_percentage
|
||||
* @return string
|
||||
*/
|
||||
public function get_item_tax(string $quantity, string $price, string $discount_percentage, string $tax_percentage): string
|
||||
{
|
||||
$tax_included = $this->appconfig->get_value('tax_included', Migration_Sales_Tax_Data::YES) == Migration_Sales_Tax_Data::YES;
|
||||
|
||||
$price = $this->get_item_total($quantity, $price, $discount_percentage, true);
|
||||
|
||||
if($tax_included)
|
||||
{
|
||||
$tax_fraction = bcadd('100', $tax_percentage);
|
||||
$tax_fraction = bcdiv($tax_fraction, '100');
|
||||
$price_tax_excl = bcdiv($price, $tax_fraction);
|
||||
|
||||
return bcsub($price, $price_tax_excl);
|
||||
}
|
||||
$tax_fraction = bcdiv($tax_percentage, '100');
|
||||
|
||||
return bcmul($price, $tax_fraction);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tax_basis
|
||||
* @param string $tax_percentage
|
||||
* @param int $rounding_mode
|
||||
* @param int $decimals
|
||||
* @return float
|
||||
*/
|
||||
public function get_sales_tax_for_amount(string $tax_basis, string $tax_percentage, int $rounding_mode, int $decimals): float
|
||||
{
|
||||
$tax_fraction = bcdiv($tax_percentage, '100');
|
||||
$tax_amount = bcmul($tax_basis, $tax_fraction);
|
||||
|
||||
return $this->round_number($rounding_mode, $tax_amount, $decimals);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $rounding_mode
|
||||
* @param string $amount
|
||||
* @param int $decimals
|
||||
* @return float
|
||||
*/
|
||||
public function round_number(int $rounding_mode, string $amount, int $decimals): float
|
||||
{
|
||||
if($rounding_mode == Migration_Sales_Tax_Data::ROUND_UP)
|
||||
{
|
||||
$fig = pow(10,$decimals);
|
||||
$rounded_total = (ceil($fig * $amount) + ceil($fig * $amount - ceil($fig * $amount)))/$fig;
|
||||
}
|
||||
elseif($rounding_mode == Migration_Sales_Tax_Data::ROUND_DOWN)
|
||||
{
|
||||
$fig = pow(10,$decimals);
|
||||
$rounded_total = (floor($fig * $amount) + floor($fig * $amount - floor($fig * $amount)))/$fig;
|
||||
}
|
||||
elseif($rounding_mode == Migration_Sales_Tax_Data::HALF_FIVE)
|
||||
{
|
||||
$rounded_total = round($amount / 5) * 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
$rounded_total = round($amount, $decimals, $rounding_mode);
|
||||
}
|
||||
|
||||
return $rounded_total; //TODO: I don't think this is currency safe. I think we need to be using bcmath() functions like we are in the rest of the code.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $sales_taxes
|
||||
* @param string $tax_type
|
||||
* @param string $tax_group
|
||||
* @param float $tax_rate
|
||||
* @param string $tax_basis
|
||||
* @param string $item_tax_amount
|
||||
* @param int $tax_group_sequence
|
||||
* @param int $rounding_code
|
||||
* @param int $sale_id
|
||||
* @param string $name
|
||||
* @param string $tax_code
|
||||
* @return void
|
||||
*/
|
||||
public function update_sales_taxes(array &$sales_taxes, string $tax_type, string $tax_group, float $tax_rate, string $tax_basis, string $item_tax_amount, int $tax_group_sequence, int $rounding_code, int $sale_id, string $name = '', string $tax_code = ''): void
|
||||
{
|
||||
$tax_group_index = $this->clean('X'.$tax_group);
|
||||
if(!array_key_exists($tax_group_index, $sales_taxes))
|
||||
{
|
||||
$insertkey = $tax_group_index; //TODO: $insertkey does not follow naming conventions.
|
||||
$sales_tax = [
|
||||
$insertkey => [
|
||||
'sale_id' => $sale_id,
|
||||
'tax_type' => $tax_type,
|
||||
'tax_group' => $tax_group,
|
||||
'sale_tax_basis' => $tax_basis,
|
||||
'sale_tax_amount' => $item_tax_amount,
|
||||
'print_sequence' => $tax_group_sequence,
|
||||
'name' => $name,
|
||||
'tax_rate' => $tax_rate,
|
||||
'sales_tax_code' => $tax_code,
|
||||
'rounding_code' => $rounding_code
|
||||
]
|
||||
];
|
||||
//add to existing array
|
||||
$sales_taxes += $sales_tax;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Important ... the sales amounts are accumulated for the group at the maximum configurable scale value of 4
|
||||
// but the scale will in reality be the scale specified by the tax_decimal configuration value used for sales_items_taxes
|
||||
$sales_taxes[$tax_group_index]['sale_tax_basis'] = bcadd($sales_taxes[$tax_group_index]['sale_tax_basis'], $tax_basis, 4);
|
||||
$sales_taxes[$tax_group_index]['sale_tax_amount'] = bcadd($sales_taxes[$tax_group_index]['sale_tax_amount'], $item_tax_amount, 4);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
public function clean(string $string): string //TODO: $string is not a good name for this variable
|
||||
{
|
||||
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
|
||||
|
||||
return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $sales_taxes
|
||||
* @return void
|
||||
*/
|
||||
public function apply_invoice_taxing(array &$sales_taxes): void
|
||||
{
|
||||
if(!empty($sales_taxes)) //TODO: Duplicated code
|
||||
{
|
||||
$sort = [];
|
||||
|
||||
foreach($sales_taxes as $key => $value)
|
||||
{
|
||||
$sort['print_sequence'][$key] = $value['print_sequence'];
|
||||
}
|
||||
|
||||
array_multisort($sort['print_sequence'], SORT_ASC, $sales_taxes);
|
||||
}
|
||||
|
||||
$decimals = totals_decimals();
|
||||
|
||||
foreach($sales_taxes as $row_number => $sales_tax)
|
||||
{
|
||||
$sales_taxes[$row_number]['sale_tax_amount'] = $this->get_sales_tax_for_amount($sales_tax['sale_tax_basis'], $sales_tax['tax_rate'], $sales_tax['rounding_code'], $decimals);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $sales_taxes
|
||||
* @return void
|
||||
*/
|
||||
public function round_sales_taxes(array &$sales_taxes): void
|
||||
{
|
||||
if(!empty($sales_taxes))
|
||||
{
|
||||
$sort = [];
|
||||
foreach($sales_taxes as $k=>$v)
|
||||
{
|
||||
$sort['print_sequence'][$k] = $v['print_sequence'];
|
||||
}
|
||||
array_multisort($sort['print_sequence'], SORT_ASC, $sales_taxes);
|
||||
}
|
||||
|
||||
$decimals = totals_decimals();
|
||||
|
||||
foreach($sales_taxes as $row_number => $sales_tax)
|
||||
{
|
||||
$sale_tax_amount = $sales_tax['sale_tax_amount'];
|
||||
$rounding_code = $sales_tax['rounding_code'];
|
||||
$rounded_sale_tax_amount = $sale_tax_amount;
|
||||
|
||||
if ($rounding_code == PHP_ROUND_HALF_UP
|
||||
|| $rounding_code == PHP_ROUND_HALF_DOWN
|
||||
|| $rounding_code == PHP_ROUND_HALF_EVEN
|
||||
|| $rounding_code == PHP_ROUND_HALF_ODD)
|
||||
{
|
||||
$rounded_sale_tax_amount = round($sale_tax_amount, $decimals, $rounding_code);
|
||||
}
|
||||
elseif($rounding_code == Migration_Sales_Tax_Data::ROUND_UP)
|
||||
{
|
||||
$fig = (int) str_pad('1', $decimals, '0');
|
||||
$rounded_sale_tax_amount = (ceil($sale_tax_amount * $fig) / $fig);
|
||||
}
|
||||
elseif($rounding_code == Migration_Sales_Tax_Data::ROUND_DOWN)
|
||||
{
|
||||
$fig = (int) str_pad('1', $decimals, '0');
|
||||
$rounded_sale_tax_amount = (floor($sale_tax_amount * $fig) / $fig);
|
||||
}
|
||||
elseif($rounding_code == Migration_Sales_Tax_Data::HALF_FIVE)
|
||||
{
|
||||
$rounded_sale_tax_amount = round($sale_tax_amount / 5) * 5;
|
||||
}
|
||||
|
||||
$sales_taxes[$row_number]['sale_tax_amount'] = $rounded_sale_tax_amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
app/Database/Migrations/20180225100000_upgrade_to_3_2_0.php
Normal file
25
app/Database/Migrations/20180225100000_upgrade_to_3_2_0.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class Migration_Upgrade_To_3_2_0 extends Migration
|
||||
{
|
||||
/**
|
||||
* Perform a migration step.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
helper('migration');
|
||||
execute_script(APPPATH . 'Database/Migrations/sqlscripts/3.1.1_to_3.2.0.sql');
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert a migration step.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
25
app/Database/Migrations/20180501100000_upgrade_to_3_2_1.php
Normal file
25
app/Database/Migrations/20180501100000_upgrade_to_3_2_1.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class Migration_Upgrade_To_3_2_1 extends Migration
|
||||
{
|
||||
/**
|
||||
* Perform a migration step.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
helper('migration');
|
||||
execute_script(APPPATH . 'Database/Migrations/sqlscripts/3.2.0_to_3.2.1.sql');
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert a migration step.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
25
app/Database/Migrations/20181015100000_attributes.php
Normal file
25
app/Database/Migrations/20181015100000_attributes.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class Migration_Attributes extends Migration
|
||||
{
|
||||
/**
|
||||
* Perform a migration step.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
helper('migration');
|
||||
execute_script(APPPATH . 'Database/Migrations/sqlscripts/3.3.0_attributes.sql');
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert a migration step.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user