Compare commits
782 commits
production
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
630796df85 | ||
| dedfb58a28 | |||
| 1b24e68f6b | |||
|
|
dc4d5f90a7 | ||
|
|
0179a1b87e | ||
|
|
f1609b2273 | ||
| 22215ff9f6 | |||
|
|
6994d69020 | ||
|
|
83bdb5c626 | ||
|
|
5a5113b166 | ||
|
|
629cc2afa1 | ||
|
|
ad946247ba | ||
|
|
63902e5838 | ||
|
|
511aa5ec9b | ||
|
|
2df53674c4 | ||
|
|
4ab6b0659d | ||
|
|
a66d16a58b | ||
|
|
5f2ed34d8c | ||
|
|
e7d8af516e | ||
|
|
8da5381a1c | ||
|
|
f8d90cbdcd | ||
|
|
6139e649fb | ||
|
|
e1103cf108 | ||
|
|
a10f58e425 | ||
|
|
23d814d1e9 | ||
|
|
9b63139957 | ||
|
|
a335f84a13 | ||
|
|
8992fdeec0 | ||
|
|
57b4227da9 | ||
|
|
bff1f7ff73 | ||
|
|
e8b14ff379 | ||
|
|
44b3753ece | ||
|
|
a21ed66490 | ||
| 3fc04cd733 | |||
|
|
3b287236ec | ||
|
|
204c039fba | ||
|
|
b4057de938 | ||
| 2a30787dba | |||
| acee5f8f55 | |||
| 90628f0b54 | |||
| 4ccdd29ae6 | |||
| 2f9ee4ec67 | |||
| 4b5ad97225 | |||
|
|
e83de164c1 | ||
| 8c886c4dbf | |||
|
|
10c44fbe64 | ||
|
|
b5f169c14e | ||
|
|
cec648f894 | ||
|
|
c4b0513386 | ||
|
|
90838b004a | ||
|
|
c60a39c13e | ||
|
|
792db080a1 | ||
|
|
08084f682c | ||
|
|
3846ad5a43 | ||
|
|
191a02f4c4 | ||
|
|
e97cebd2b2 | ||
|
|
952122a39e | ||
|
|
ad841a7e25 | ||
|
|
75b2ada03f | ||
|
|
4b19cff996 | ||
|
|
2ebb6e040a | ||
|
|
404401d854 | ||
|
|
6dfaeee799 | ||
|
|
aae4aaa390 | ||
|
|
b53aacb840 | ||
|
|
22683e1edf | ||
|
|
4be9134090 | ||
|
|
21c97df677 | ||
|
|
5cf2c3619f | ||
|
|
7b6afbb099 | ||
|
|
190ac88153 | ||
|
|
aed31f2a33 | ||
|
|
76496ed6fe | ||
|
|
89e5dd799f | ||
|
|
0bd6a89840 | ||
|
|
be0e69db89 | ||
|
|
d52402a2ef | ||
|
|
a45c3dd65c | ||
|
|
b19d9c203a | ||
|
|
a64557ffcd | ||
|
|
d7909f7941 | ||
|
|
8e383fd23f | ||
|
|
86889b3147 | ||
| 6a804c11df | |||
| c8e2c02be1 | |||
|
|
06dc8eae7b | ||
|
|
f97f287f5b | ||
| 6f2fca292e | |||
| b80ece9084 | |||
| 90aada4bf3 | |||
| 93c313f111 | |||
|
|
25e0931f6f | ||
|
|
5af3a3cb5e | ||
| bf0d1f664b | |||
|
|
07b459e7a3 | ||
|
|
c4e03f861d | ||
|
|
cd21e41d2f | ||
|
|
1a6af00399 | ||
|
|
c03025748f | ||
|
|
ca513355fe | ||
|
|
9152370300 | ||
|
|
bff89a6817 | ||
|
|
a59aa0f66d | ||
|
|
69218aecf4 | ||
|
|
47dcd92474 | ||
|
|
9f4c16b149 | ||
|
|
175ac92765 | ||
|
|
801a274e8c | ||
|
|
d603934d93 | ||
|
|
a4b883b7ea | ||
|
|
a2cd86b48c | ||
| 5ddebcd95f | |||
|
|
ef5e629358 | ||
|
|
4dd8efd95a | ||
| 34adefb798 | |||
|
|
78a43ae85c | ||
| 7ed9f90945 | |||
|
|
0a4f78559c | ||
|
|
270a4cfb10 | ||
|
|
7a5583d840 | ||
| 4d89e7420f | |||
| 010bdca458 | |||
| abf4bbfe22 | |||
|
|
eebd1d93c4 | ||
|
|
ba09e6ac7b | ||
|
|
8860796db2 | ||
|
|
3254527653 | ||
| 8ca7292a25 | |||
| c9057b9617 | |||
| 86744afde3 | |||
| ae46d64f5b | |||
|
|
a5340fbfd6 | ||
| 0e5365a015 | |||
|
|
313dc74eb0 | ||
|
|
33eaf9bbff | ||
|
|
8ee1809a99 | ||
| 5717eddaa0 | |||
|
|
35b3b23e55 | ||
| f7c8034538 | |||
|
|
ba8ac73c9d | ||
| 9b52d4578f | |||
|
|
b033e5674d | ||
| 0e2afaa400 | |||
|
|
b123be25cc | ||
| d4eae00902 | |||
| 20f5bb08e0 | |||
| 213171f4b7 | |||
| c136b0666b | |||
| 57fd7fe5ac | |||
| bc6364ace5 | |||
| c5b395d720 | |||
| b6763bfd3e | |||
| 29ad8d57a4 | |||
|
|
70ee7fdd89 | ||
|
|
ee033ddd55 | ||
|
|
a83fecf224 | ||
|
|
9de6fa7999 | ||
|
|
6d7c8c5b53 | ||
|
|
022336ad8f | ||
|
|
bfe7a5fbf6 | ||
|
|
b592390554 | ||
|
|
7f4675a8a2 | ||
|
|
f65ca19010 | ||
| c17be92f0a | |||
| 80b9f90324 | |||
| 01e4baa8c4 | |||
| e4ffcc0c9d | |||
|
|
9c081b416e | ||
|
|
5ee41dab32 | ||
|
|
58f46fd5bf | ||
|
|
8c810bf27a | ||
|
|
fa3cf12be1 | ||
|
|
9447f64312 | ||
|
|
b51160e9d0 | ||
|
|
d8bd2803e0 | ||
|
|
a7c7b03d06 | ||
|
|
ebfa3495a7 | ||
|
|
7c09dcac65 | ||
|
|
fb2ca0bbd8 | ||
|
|
9bc9b13055 | ||
|
|
4773d6c08c | ||
|
|
fd0c9ede26 | ||
|
|
ef10f7c7b9 | ||
|
|
6d4614f634 | ||
|
|
cf5da6ea7b | ||
|
|
2e5ce7e28b | ||
|
|
deb26d3aa8 | ||
|
|
1dbfd2e3d1 | ||
|
|
6cf94bb193 | ||
|
|
14d62d044f | ||
|
|
fba077d4d3 | ||
|
|
c7b2502f0a | ||
|
|
0ded3cea83 | ||
|
|
1ce284578d | ||
|
|
24332c0f9b | ||
|
|
91edfa6ef0 | ||
|
|
005f891057 | ||
|
|
c77591fe01 | ||
|
|
fd28be75d1 | ||
|
|
806418db52 | ||
|
|
35456cfb19 | ||
|
|
58c3d1c64a | ||
|
|
e070d6df18 | ||
|
|
ac5683f7f1 | ||
|
|
0ba63cc106 | ||
|
|
8ed1434353 | ||
|
|
b20371cd1f | ||
|
|
2344ec716b | ||
|
|
d44323c097 | ||
|
|
561a280647 | ||
|
|
20a6029671 | ||
|
|
ff753d5452 | ||
|
|
2432a08c4d | ||
|
|
a29c31d3de | ||
|
|
b1ff62d9ec | ||
|
|
ac2cf864f2 | ||
|
|
708e9a67cc | ||
|
|
38262151e8 | ||
|
|
502e9a11cd | ||
|
|
da87b386a3 | ||
|
|
d3054760d3 | ||
|
|
c332757a53 | ||
|
|
516fbcfcba | ||
|
|
c0c6fe26f7 | ||
|
|
cbe84d1cc8 | ||
|
|
e3a79361bd | ||
|
|
9b616cf398 | ||
|
|
dd9c9dd0ec | ||
|
|
38023bdb00 | ||
|
|
a002da6aad | ||
|
|
ee021da453 | ||
|
|
78956de357 | ||
|
|
c5a8bda95a | ||
|
|
4dbd2377f4 | ||
|
|
95f771c252 | ||
|
|
db75e7becd | ||
|
|
8c11ec9e8f | ||
|
|
f94cec4bfa | ||
|
|
041248ae0c | ||
|
|
d00b211363 | ||
|
|
32f3f957be | ||
|
|
fc95f781d8 | ||
|
|
f98b3e170c | ||
|
|
555e79ab68 | ||
|
|
80c762d463 | ||
|
|
4f13114649 | ||
|
|
cfa77bf2e1 | ||
|
|
e9631b437f | ||
|
|
3af04a922a | ||
|
|
8f196000a8 | ||
|
|
236819d951 | ||
|
|
70047d4ea0 | ||
|
|
f481af3694 | ||
|
|
acf7ce0d4d | ||
|
|
de5f55ac0e | ||
|
|
3137d39a9a | ||
|
|
b3b81e4e27 | ||
|
|
18c295f2b1 | ||
|
|
9ad1f0d9b2 | ||
|
|
73738b7a18 | ||
|
|
e3af21f741 | ||
|
|
4516566d56 | ||
|
|
26824713da | ||
|
|
f3992f05fc | ||
|
|
e212e2d29a | ||
|
|
458a34c6a8 | ||
|
|
1704235bbd | ||
|
|
0708ebdca9 | ||
|
|
00eb5d1a9d | ||
|
|
570d405347 | ||
|
|
18c893cc6e | ||
|
|
7b16738709 | ||
|
|
da419dd257 | ||
|
|
49ff4b604b | ||
|
|
fc33668a46 | ||
|
|
9b75993d3d | ||
|
|
6d6662611d | ||
|
|
0eef2449e8 | ||
|
|
c2ff927f1f | ||
|
|
4f70fc437c | ||
|
|
bc47873ed1 | ||
|
|
8427b3fb3d | ||
|
|
a78c08b7a2 | ||
|
|
976acc26ad | ||
|
|
11355f3eb2 | ||
|
|
20301b6b98 | ||
|
|
97917cf49b | ||
|
|
f26d6284f3 | ||
|
|
12ebe3538c | ||
|
|
37ce74f07d | ||
|
|
17e0fd6dcf | ||
|
|
54c49eb8c5 | ||
|
|
2f3a77e96d | ||
|
|
b4bcc06e42 | ||
|
|
7beeef104c | ||
|
|
87f77c9b9c | ||
|
|
abc4e31d96 | ||
|
|
783c26facc | ||
|
|
822bc59c6c | ||
|
|
9840ecf633 | ||
| ee9031a8f3 | |||
|
|
f9800d8da3 | ||
|
|
b81b10840b | ||
|
|
c2418b117e | ||
|
|
31c0f4a102 | ||
|
|
c4878a9e6d | ||
|
|
5540084416 | ||
|
|
4990a3dc9d | ||
|
|
282760fe5a | ||
|
|
05073f3a0c | ||
|
|
fa514ef26c | ||
|
|
e9f18ed184 | ||
|
|
4ebbd8cfd3 | ||
|
|
fe5121cf71 | ||
|
|
a986d7835b | ||
|
|
77c2763f53 | ||
|
|
f760b2c02a | ||
|
|
725704e951 | ||
|
|
49317188c9 | ||
|
|
f598e4f426 | ||
|
|
9bac6df2df | ||
|
|
82065bda93 | ||
|
|
e3ec6148df | ||
|
|
15830924e2 | ||
|
|
0063f10f93 | ||
|
|
0bb32f47b5 | ||
|
|
ed037428b3 | ||
|
|
0b3b5eb0bb | ||
|
|
1c02138f52 | ||
|
|
562e96e32d | ||
|
|
e235026197 | ||
|
|
a821c42f0d | ||
|
|
33e6994aaa | ||
|
|
c2c4be8b7b | ||
|
|
f2233d6680 | ||
|
|
9afa2dfc6c | ||
|
|
059bda9bf6 | ||
|
|
9b7e0e55a7 | ||
|
|
24bd64d6e0 | ||
|
|
202b2d740e | ||
|
|
8241dc5630 | ||
|
|
58eafabdcf | ||
|
|
9c36baa3d3 | ||
|
|
551a39a236 | ||
|
|
8d7556c732 | ||
|
|
b90fc2f8dd | ||
|
|
c32b7d68c7 | ||
|
|
63526d65f2 | ||
|
|
ea60fa081c | ||
|
|
4f06c02bd4 | ||
|
|
1d278beb35 | ||
|
|
0afc1a04b0 | ||
|
|
fa3998d47f | ||
|
|
a52267ca76 | ||
|
|
3861a9bf93 | ||
|
|
ddde274fdc | ||
|
|
82578fb346 | ||
|
|
e24174e59e | ||
|
|
5f4e6b1ad9 | ||
|
|
8e53a3bb19 | ||
|
|
219ab513b5 | ||
|
|
87702f0e4c | ||
|
|
df6a4ad292 | ||
|
|
13531171d7 | ||
|
|
1ed25d0a26 | ||
|
|
1261fc1d20 | ||
|
|
3bf350ceaf | ||
|
|
4182e44607 | ||
|
|
fed0b655f5 | ||
|
|
68fe13de46 | ||
|
|
403de63251 | ||
|
|
bddddf1970 | ||
| da03f13f75 | |||
|
|
2535498db9 | ||
|
|
f6436cd421 | ||
|
|
46104bc395 | ||
|
|
cb11849489 | ||
|
|
6d416ee5f1 | ||
|
|
c7fc06ef50 | ||
| bc7a91c01d | |||
|
|
92abe703d3 | ||
| e2498beca7 | |||
| f6a858cc28 | |||
|
|
674a862586 | ||
|
|
e102766961 | ||
|
|
a594bef863 | ||
|
|
2aef8e64e7 | ||
|
|
4717d7d925 | ||
|
|
f57c9f5f4f | ||
|
|
d59ac805f7 | ||
|
|
95b5c59db2 | ||
|
|
202b984aa2 | ||
|
|
f7f182e062 | ||
|
|
0947b12e99 | ||
|
|
2f7e493fab | ||
|
|
5dc4d9f3f8 | ||
|
|
81d4f46930 | ||
| 87846040b6 | |||
| 71ee183813 | |||
|
|
b87855e0a6 | ||
| 2c6b39acb6 | |||
| 8cdf33014e | |||
| 0331fb605a | |||
|
|
e3be92b63e | ||
|
|
f62ce78ac7 | ||
| 1ecd69b959 | |||
| af39b6d6ca | |||
|
|
efec5c4b84 | ||
|
|
693ee7cd9b | ||
|
|
e0029d8ab5 | ||
|
|
879c80f7be | ||
|
|
98705f99d4 | ||
|
|
9876165af5 | ||
|
|
b3301fdbac | ||
|
|
ab2d6be08e | ||
|
|
765b3a99b9 | ||
| 51a2111552 | |||
|
|
0e7a955a91 | ||
|
|
63b02a7c21 | ||
|
|
2a0ca3b9ea | ||
|
|
4c4a8da7e6 | ||
|
|
876722ebe7 | ||
|
|
6e9e56b1be | ||
|
|
72fc6ee9b0 | ||
|
|
cbf5d12d96 | ||
|
|
c478a4d0bf | ||
| 935dc15101 | |||
|
|
fd2a1b35bc | ||
| c8d22a0dfb | |||
|
|
7cd8dcf725 | ||
| 08ecd2ebea | |||
|
|
54b5d0deef | ||
| d5245844ac | |||
|
|
7c95f1ff0d | ||
|
|
79caebf1f9 | ||
| 31b246fca0 | |||
|
|
6d6c855feb | ||
| 524d99db08 | |||
|
|
bec964ffa4 | ||
|
|
907bee0d70 | ||
|
|
5b6b090257 | ||
| 8776d69a92 | |||
|
|
c70dbd3b52 | ||
| f0d14b7d77 | |||
|
|
8d9c02ae72 | ||
|
|
29468c629b | ||
|
|
f2a661f696 | ||
|
|
b1d7777726 | ||
|
|
2317bfee4d | ||
|
|
b9159b7f4a | ||
|
|
1b3d8d86a0 | ||
| 36ad7a28c2 | |||
| a5640914bf | |||
|
|
0ece8b5864 | ||
| 9f2027fcc1 | |||
|
|
ab77cb6260 | ||
| 337b98f655 | |||
|
|
9112bf55f1 | ||
|
|
36cf10871e | ||
|
|
474298a42b | ||
| 5e22dc5de1 | |||
|
|
49df3fc976 | ||
| e08a4ed803 | |||
|
|
1c3032b9e7 | ||
| 9130d41a96 | |||
|
|
a3be1434a0 | ||
|
|
b3678168da | ||
|
|
b4a6e233f1 | ||
|
|
6794db5f6a | ||
|
|
97d058c3d3 | ||
|
|
815c25a894 | ||
|
|
21231358d6 | ||
| c1ef75b8f5 | |||
|
|
b8c0fa9932 | ||
| 72dab63503 | |||
|
|
c077094044 | ||
| 53d4d28716 | |||
|
|
6ee6a7d9a1 | ||
|
|
9efe73e8b2 | ||
|
|
f40155e1f5 | ||
|
|
2bbb83c43e | ||
|
|
6314b4097d | ||
|
|
138c60a61b | ||
|
|
f8910860a6 | ||
|
|
fc15b514bf | ||
|
|
0ffbf10879 | ||
|
|
c42d2973f4 | ||
| 7416be8425 | |||
|
|
35d6e34128 | ||
|
|
d9aaea928c | ||
|
|
70e9b933d9 | ||
|
|
cbc0b290ad | ||
|
|
32720ba9e7 | ||
|
|
5b848a7f10 | ||
|
|
a3e9c45ec3 | ||
|
|
3c9bdc8152 | ||
|
|
7d65b1eb77 | ||
| c2adf8f082 | |||
|
|
dae8fe7051 | ||
| 5352f16b83 | |||
|
|
f51ec9112d | ||
| c1dbc8abf6 | |||
|
|
6231db2467 | ||
| 4b887adcd2 | |||
| 5d6eb443a7 | |||
| eb769f736f | |||
|
|
34accc1a0c | ||
| 091da71cc1 | |||
|
|
1feef7484e | ||
| 52545c8a4f | |||
|
|
a4338c8f61 | ||
|
|
837a3a2ec5 | ||
|
|
c1e33fb5dd | ||
|
|
5f94f252bc | ||
| a08f988a54 | |||
| 80d4063238 | |||
| 774599a01b | |||
| d27d54f7da | |||
| a327f070aa | |||
| 559d4bbc01 | |||
| ae9b7ce061 | |||
|
|
270867f86f | ||
|
|
48aa0b024f | ||
| 0ea02ae04d | |||
|
|
ce160c506c | ||
|
|
3910db88f0 | ||
|
|
ee44dfb44e | ||
|
|
06a2a887ef | ||
|
|
470dd47195 | ||
|
|
accd6fd0f6 | ||
|
|
7995706dd3 | ||
|
|
a669159513 | ||
| c2d556b1b6 | |||
|
|
873bf80154 | ||
| 4e728fd59a | |||
|
|
3ce12df214 | ||
| b4def3c1a7 | |||
|
|
bbb562d366 | ||
|
|
fd77f1ef62 | ||
|
|
2112edd4f0 | ||
|
|
144afae551 | ||
|
|
4e613e3c01 | ||
|
|
3e73bc0513 | ||
|
|
f486a1b5a0 | ||
|
|
7985ec8f34 | ||
|
|
ce6b1f8049 | ||
| 7b01e7bc0d | |||
|
|
5b32349437 | ||
|
|
fb91d462ff | ||
|
|
2ca7f86829 | ||
|
|
fb766eb99f | ||
|
|
08050416bb | ||
|
|
db65c6d623 | ||
|
|
c8a8bc53af | ||
|
|
89cd852db8 | ||
|
|
16fb2cf0da | ||
|
|
c885033934 | ||
|
|
44b9679a2e | ||
|
|
60f401e26e | ||
| 54f065d30f | |||
| 0734f315ac | |||
| b68d722013 | |||
| 11432f9742 | |||
|
|
a9a5760444 | ||
|
|
200f4bca22 | ||
|
|
f8e3e7df2d | ||
| 4eb35364ca | |||
| f90badd331 | |||
| 9150db3c20 | |||
|
|
cf97c74ea6 | ||
|
|
c63b9ffe43 | ||
|
|
3af014c7cf | ||
|
|
d2591a3ffb | ||
|
|
feade62c18 | ||
|
|
86ab8edb74 | ||
| 50ce917a1a | |||
|
|
61c7774da0 | ||
|
|
1a290436cb | ||
|
|
70d917a585 | ||
|
|
a847cba9b9 | ||
| 80e61bbc92 | |||
|
|
3b80fee75f | ||
|
|
d89f67bc76 | ||
|
|
96ce1f81fa | ||
|
|
efd402acb1 | ||
|
|
5840aba2a9 | ||
| 16e0d8448f | |||
|
|
a7f52fc139 | ||
| 79f2686404 | |||
|
|
e2bdf91f1c | ||
|
|
c3ecf51468 | ||
|
|
e36523528d | ||
| 744e80a9e5 | |||
|
|
6098858332 | ||
|
|
174acddc91 | ||
| ee65a75ec2 | |||
|
|
a67ec1ec11 | ||
|
|
fe0243a4cc | ||
|
|
4580228628 | ||
|
|
da20713f0f | ||
| 9ac0c1613d | |||
|
|
70cbecb481 | ||
| 3b23c7b913 | |||
|
|
b56787e637 | ||
|
|
ff1f5bc7c6 | ||
| cc41ac4290 | |||
|
|
ba87fe61c5 | ||
|
|
941f59ab6e | ||
|
|
c8208df0f3 | ||
|
|
31e2088b6a | ||
|
|
1778af3f9f | ||
|
|
a7d1bb6a90 | ||
|
|
fa02cd1a67 | ||
| b343d00dfc | |||
|
|
232b962c2e | ||
| 41c25ed1f5 | |||
|
|
4803152fb1 | ||
|
|
3f9fd88729 | ||
|
|
c099ffd5fd | ||
|
|
f89e8548a9 | ||
|
|
b0e743b6e7 | ||
| 1c22b8b96f | |||
|
|
938d6ff848 | ||
|
|
4afa21f51e | ||
|
|
559a61bb13 | ||
|
|
9318b37077 | ||
|
|
0dda309a76 | ||
|
|
d9de5cd519 | ||
|
|
1a7d53ca01 | ||
| 3a00a46b73 | |||
|
|
8401eeb0da | ||
|
|
e8670e4b60 | ||
|
|
86ef1ec646 | ||
|
|
ecff27524a | ||
|
|
39be9e94ed | ||
|
|
a9cb98912c | ||
| 413d963348 | |||
|
|
5adbc79363 | ||
| 102f0962bf | |||
|
|
0ea329655f | ||
|
|
19d12d9264 | ||
|
|
3e61bdb89c | ||
|
|
4fb28174c5 | ||
| 4c67d59b22 | |||
|
|
e44d8d3b06 | ||
| ca4c59f59e | |||
|
|
ebaef97333 | ||
|
|
bbea317cf1 | ||
|
|
0dee028045 | ||
| 4a93a2d482 | |||
|
|
4d07f350bb | ||
|
|
cea8df1a2c | ||
| 19a757f48d | |||
|
|
dad3caecf3 | ||
| 2caa286f12 | |||
|
|
9bc1f44ca2 | ||
|
|
b712b35a97 | ||
|
|
6fff162c0e | ||
|
|
a6add363bd | ||
|
|
466d6c124f | ||
| ab2ca02227 | |||
|
|
688b890fd7 | ||
| d0d26e01e4 | |||
|
|
bc1c6110e8 | ||
| 7433fd5153 | |||
|
|
928257ccdc | ||
|
|
a50d591160 | ||
|
|
6cc9cddf1f | ||
|
|
b831deacfb | ||
|
|
789c919179 | ||
| 9b50efc9d0 | |||
|
|
4e1613540d | ||
|
|
618769ab5d | ||
|
|
3315565000 | ||
| b4f28a3b17 | |||
|
|
3e238347be | ||
| f9647f3337 | |||
|
|
c8629692e9 | ||
|
|
85be728bf6 | ||
| b7159c127c | |||
|
|
73f0e69b9a | ||
|
|
e80ce9db66 | ||
|
|
457bbece2b | ||
|
|
b7c5f5dafe | ||
|
|
d8f5b7833d | ||
| b16e58cf35 | |||
|
|
8c685536d3 | ||
| 1d627025eb | |||
|
|
a5a30ec7f9 | ||
|
|
ae477ea440 | ||
| 5686923a04 | |||
|
|
4765c34be8 | ||
| e986d07f70 | |||
| 5b36e0d8d7 | |||
| c9fe5ffce5 | |||
| b1150d6c93 | |||
| aa529e7411 | |||
| a5f5ac861d | |||
| 255395bb38 | |||
|
|
8c057c216e | ||
|
|
5c03ccb1fb | ||
|
|
b0de01ae1b | ||
|
|
2e428378c6 | ||
|
|
3dd2bf5de4 | ||
|
|
9c73a18b2e | ||
|
|
680a12e52a | ||
|
|
0e5824af29 | ||
|
|
ca21fcd5c9 | ||
|
|
1030b1934e | ||
|
|
65c0ad1c56 | ||
|
|
280a7c9c8f | ||
|
|
c108647222 | ||
| ee07c9cc84 | |||
| cc12e150f4 | |||
| 11c323f39a | |||
|
|
09405d16ce | ||
|
|
05d50e28f7 | ||
|
|
a7d6f20cc4 | ||
|
|
f9de11ccb5 | ||
|
|
8d5b67b020 | ||
|
|
12c85e5cbb | ||
|
|
4ce09e9671 | ||
|
|
acf5d964cf | ||
| 4d66345ae3 | |||
|
|
0dce53beaa | ||
|
|
5c61e5ebea | ||
|
|
4a1ae91b78 | ||
|
|
918c06725e | ||
|
|
1f6162cb47 | ||
|
|
1d93c63da7 | ||
|
|
8ebb123064 | ||
|
|
158d05d822 | ||
|
|
16c944899f | ||
|
|
f7def95cdd | ||
| 07f7457937 | |||
|
|
b14007e276 | ||
|
|
7001d6a0ed | ||
|
|
84844046f1 | ||
|
|
c54ee5d7d8 | ||
|
|
e4e412fd14 | ||
|
|
3f7075f26d | ||
|
|
48aaeddadd | ||
|
|
ca3fbc21c8 | ||
|
|
61b897d883 | ||
|
|
a8eaad2a82 | ||
|
|
9c31a573c6 | ||
| 764c9e690c | |||
|
|
0fe66f4719 | ||
|
|
44611915e5 | ||
| 97070ded9a | |||
|
|
50c67d7088 | ||
|
|
9f5493c125 | ||
|
|
6fe63050c6 | ||
|
|
b9fdcbbbbb | ||
| 1f067dd2ef | |||
|
|
46ea41f034 | ||
|
|
e9fa25dada | ||
|
|
c955516acf | ||
|
|
f8ebe0d97a | ||
|
|
9b7852d248 | ||
|
|
d366106381 | ||
|
|
c2066b86c9 | ||
|
|
0065bc94ef | ||
| 94f2cc75a7 | |||
|
|
d750c6b8ba | ||
| 8056cb6d29 | |||
|
|
840cbe2463 | ||
|
|
e6d3043556 | ||
|
|
fe15385613 | ||
| 38ce447b0a | |||
|
|
c6654bd3c6 | ||
| 697fa20071 | |||
|
|
21cf667b47 | ||
| 1db04374ec | |||
|
|
f43d2f10fe | ||
| 0ababa77c2 | |||
|
|
8dd06b2d5e | ||
| 8ef2617f87 | |||
|
|
89370b4bd0 | ||
| 4ea21f7004 | |||
|
|
e820051d0e | ||
|
|
93d4282257 |
3
.gitignore
vendored
|
|
@ -12,3 +12,6 @@
|
|||
|
||||
*.swp
|
||||
/public/warranty_uploads/*
|
||||
.vscode
|
||||
*__pycache__
|
||||
/public/assets/images/insurance-premiums.png
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Access;
|
||||
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as BaseGenerator;
|
||||
|
||||
class Generator extends BaseGenerator
|
||||
{
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Access;
|
||||
|
||||
use Catalyst\AuthBundle\Service\ACLVoter as BaseVoter;
|
||||
|
||||
class Voter extends BaseVoter
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class CatalystAPIBundle extends Bundle
|
||||
{
|
||||
}
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||
|
||||
use Catalyst\APIBundle\Connector\Client as APIClient;
|
||||
|
||||
|
||||
class TestAPICommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('api:test-connector-all')
|
||||
->setDescription('Test API connector with all commands.')
|
||||
->setHelp('Test API Connector with all commands.')
|
||||
->addArgument('protocol', InputArgument::REQUIRED, 'protocol')
|
||||
->addArgument('server', InputArgument::REQUIRED, 'server')
|
||||
->addArgument('api_key', InputArgument::REQUIRED, 'api_key')
|
||||
->addArgument('secret_key', InputArgument::REQUIRED, 'secret_key');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$protocol = $input->getArgument('protocol');
|
||||
$server = $input->getArgument('server');
|
||||
$api_key = $input->getArgument('api_key');
|
||||
$secret_key = $input->getArgument('secret_key');
|
||||
|
||||
// api client
|
||||
$api = new APIClient($server, $api_key, $secret_key);
|
||||
$api->setProtocol($protocol);
|
||||
|
||||
// test
|
||||
$api->get('/capi/test');
|
||||
|
||||
// TODO: shift this out of the bundle, since it's project specific
|
||||
|
||||
// warranty register
|
||||
$serial = 'AJ34LJADR12134LKJL5';
|
||||
$plate_num = 'XEN918';
|
||||
$params = [
|
||||
'serial' => $serial,
|
||||
'plate_number' => $plate_num,
|
||||
'warranty_class' => 'private',
|
||||
'sku' => 'WMEB24CB-CPN00-LX',
|
||||
'date_purchase' => '20181001',
|
||||
'date_expire' => '20191001',
|
||||
'first_name' => 'First',
|
||||
'last_name' => 'Last',
|
||||
'mobile_number' => '09231234567',
|
||||
];
|
||||
//$api->post('/capi/warranties', $params);
|
||||
|
||||
// get all warranties
|
||||
$params = [
|
||||
'order' => 'DESC',
|
||||
'limit' => '5',
|
||||
'start' => '1',
|
||||
];
|
||||
|
||||
//$api->get('/capi/warranties', $params);
|
||||
|
||||
|
||||
// warranty find
|
||||
//$api->get('/capi/warranties/' . $serial);
|
||||
|
||||
// warranty update
|
||||
$id = 86811;
|
||||
$params = [
|
||||
'serial' => $serial,
|
||||
'plate_number' => $plate_num,
|
||||
'warranty_class' => 'private',
|
||||
'sku' => 'WMEB24CB-CPN00-LX',
|
||||
'date_purchase' => '20181001',
|
||||
'date_expire' => '20191001',
|
||||
'first_name' => 'First',
|
||||
'last_name' => 'Last',
|
||||
'mobile_number' => '123456789111',
|
||||
];
|
||||
//$api->post('/capi/warranties/'. $id, $params);
|
||||
|
||||
// warranty set privacy policy
|
||||
$id = 86811;
|
||||
$policy_id = 2;
|
||||
$params = [
|
||||
'privacy_policy_id' => $policy_id,
|
||||
];
|
||||
//$api->post('/capi/warranties/' . $id .'/privacypolicy', $params);
|
||||
|
||||
// warranty claim
|
||||
$id = 86811;
|
||||
$serial = 'AJ34LJADR12134LKJL5';
|
||||
$params = [
|
||||
'serial' => $serial,
|
||||
];
|
||||
//$api->post('/capi/warranties/' . $id . '/claim', $params);
|
||||
|
||||
// warranty cancel
|
||||
$id = 86811;
|
||||
//$api->get('/capi/warranties/' . $id . '/cancel');
|
||||
|
||||
// plate warranty
|
||||
//$api->get('/capi/plates/' . $plate_num . '/warranties');
|
||||
|
||||
// warranty delete
|
||||
$id = 86811;
|
||||
//$api->post('/capi/warranties/' . $id . '/delete');
|
||||
|
||||
// battery
|
||||
//$api->get('/capi/battery_brands');
|
||||
//$api->get('/capi/battery_sizes');
|
||||
//$api->get('/capi/batteries');
|
||||
|
||||
// vehicle
|
||||
//$api->get('/capi/vehicle_manufacturers');
|
||||
//$api->get('/capi/vehicles');
|
||||
|
||||
// privacy policy
|
||||
$privacy_policy_id = 2;
|
||||
//$api->get('/capi/privacy_policy/' . $privacy_policy_id );
|
||||
|
||||
// register new customer
|
||||
$params = [
|
||||
'first_name' => 'Krispups',
|
||||
'last_name' =>'Porzindog',
|
||||
'mobile_number' => '9221111111',
|
||||
'v_make_id' => '22241',
|
||||
'v_model_year' => '2018',
|
||||
'v_plate_number' => 'KPP1234',
|
||||
'v_color' => 'White',
|
||||
'v_condition' => 'new',
|
||||
'v_fuel_type' => 'gas',
|
||||
];
|
||||
//$api->post('/capi/quick_registration', $params);
|
||||
|
||||
// get warranties given list of serial numbers
|
||||
$serial_list = [
|
||||
'AJ34LJADR12134LKJM4',
|
||||
'AJ34LJADR12134LKJL5',
|
||||
'test',
|
||||
];
|
||||
|
||||
$params = [
|
||||
'serial_list' => $serial_list,
|
||||
];
|
||||
|
||||
$api->post('/capi/warranties_list', $params);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||
|
||||
use Catalyst\APIBundle\Connector\Client as APIClient;
|
||||
|
||||
|
||||
class TestCommand extends Command
|
||||
{
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('api:test-connector')
|
||||
->setDescription('Test API connector.')
|
||||
->setHelp('Test API Connector.')
|
||||
->addArgument('protocol', InputArgument::REQUIRED, 'protocol')
|
||||
->addArgument('server', InputArgument::REQUIRED, 'server')
|
||||
->addArgument('api_key', InputArgument::REQUIRED, 'api_key')
|
||||
->addArgument('secret_key', InputArgument::REQUIRED, 'secret_key');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$protocol = $input->getArgument('protocol');
|
||||
$server = $input->getArgument('server');
|
||||
$api_key = $input->getArgument('api_key');
|
||||
$secret_key = $input->getArgument('secret_key');
|
||||
|
||||
// api client
|
||||
$api = new APIClient($server, $api_key, $secret_key);
|
||||
$api->setProtocol($protocol);
|
||||
|
||||
// test
|
||||
$api->get('/capi/test');
|
||||
|
||||
// TODO: shift this out of the bundle, since it's project specific
|
||||
|
||||
|
||||
// warranty register
|
||||
$serial = 'AJ34LJADR12134LKJL5';
|
||||
$plate_num = 'XEN918';
|
||||
$params = [
|
||||
'serial' => $serial,
|
||||
'plate_number' => $plate_num,
|
||||
'warranty_class' => 'private',
|
||||
'sku' => 'WMEB24CB-CPN00-LX',
|
||||
'date_purchase' => '20181001',
|
||||
'date_expire' => '20191001',
|
||||
'first_name' => 'First',
|
||||
'last_name' => 'Last',
|
||||
'mobile_number' => '12345678910',
|
||||
];
|
||||
$api->post('/capi/warranties', $params);
|
||||
|
||||
// get all warranties
|
||||
$api->get('/capi/warranties');
|
||||
|
||||
|
||||
/*
|
||||
// warranty find
|
||||
$api->get('/capi/warranties/' . $serial);
|
||||
*/
|
||||
|
||||
// warranty claim
|
||||
$id = 86811;
|
||||
$serial = 'AJ34LJADR12134LKJL';
|
||||
$params = [
|
||||
'serial' => $serial,
|
||||
];
|
||||
$api->post('/capi/warranties/' . $id . '/claim', $params);
|
||||
|
||||
// add battery
|
||||
$sku = 'WZMB31QT-CPP00-S';
|
||||
$brand_id = '4';
|
||||
$size_id = '1';
|
||||
$params = [
|
||||
'sku' => $sku,
|
||||
'brand_id' => $brand_id,
|
||||
'size_id' => $size_id,
|
||||
];
|
||||
$api->post('/capi/batteries', $params);
|
||||
|
||||
/*
|
||||
|
||||
// plate warranty
|
||||
$api->get('/capi/plates/' . $plate_num . '/warranties');
|
||||
|
||||
// battery
|
||||
$api->get('/capi/battery_brands');
|
||||
$api->get('/capi/battery_sizes');
|
||||
$api->get('/capi/batteries');
|
||||
|
||||
// vehicle
|
||||
// $api->get('/capi/vehicle_manufacturers');
|
||||
// $api->get('/capi/vehicles');
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Catalyst\APIBundle\Entity\User;
|
||||
|
||||
class UserCreateCommand extends Command
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('api:user-create')
|
||||
->setDescription('Create new API user.')
|
||||
->setHelp('Creates new API user and saves to database.')
|
||||
->addArgument('name', InputArgument::REQUIRED, 'name');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$name = $input->getArgument('name');
|
||||
|
||||
$user = new User();
|
||||
$user->setName($name);
|
||||
|
||||
$this->em->persist($user);
|
||||
$this->em->flush();
|
||||
|
||||
$output->write('API Key - ' . $user->getAPIKey() . "\n");
|
||||
$output->write('Secret Key - ' . $user->getSecretKey() . "\n");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Connector;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class Client
|
||||
{
|
||||
const HEADER_API_KEY = 'X-Cata-API-Key';
|
||||
const HEADER_SIGNATURE = 'X-Cata-Signature';
|
||||
const HEADER_DATE = 'X-Cata-Date';
|
||||
|
||||
const DATE_FORMAT = 'D, d M Y H:i:s T';
|
||||
|
||||
const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36';
|
||||
|
||||
protected $protocol;
|
||||
protected $server;
|
||||
protected $port;
|
||||
protected $api_key;
|
||||
protected $secret_key;
|
||||
|
||||
protected $curl;
|
||||
|
||||
public function __construct($server, $api_key, $secret_key)
|
||||
{
|
||||
$this->protocol = 'https';
|
||||
$this->port = null;
|
||||
|
||||
$this->server = $server;
|
||||
$this->api_key = $api_key;
|
||||
$this->secret_key = $secret_key;
|
||||
$this->curl = curl_init();
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
curl_close($this->curl);
|
||||
}
|
||||
|
||||
public function setProtocol($protocol)
|
||||
{
|
||||
if ($protocol != 'http' && $protocol != 'https')
|
||||
return $this;
|
||||
|
||||
$this->protocol = $protocol;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getDateString()
|
||||
{
|
||||
$date = new DateTime();
|
||||
return $date->format(self::DATE_FORMAT);
|
||||
}
|
||||
|
||||
public function get($url, $params = [])
|
||||
{
|
||||
curl_reset($this->curl);
|
||||
|
||||
$date_string = $this->getDateString();
|
||||
$headers = $this->generateHeaders('GET', $url, $date_string);
|
||||
|
||||
// build query string
|
||||
if (count($params) > 0)
|
||||
$query_string = '?' . http_build_query($params);
|
||||
else
|
||||
$query_string = '';
|
||||
|
||||
// build url
|
||||
if ($this->port == null)
|
||||
$full_url = $this->protocol . '://' . $this->server . $url . $query_string;
|
||||
else
|
||||
$full_url = $this->protocol . '://' . $this->server . ':' . $this->port . $url . $query_string;
|
||||
|
||||
error_log($full_url);
|
||||
|
||||
// curl
|
||||
// curl_setopt($this->curl, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($this->curl, CURLOPT_URL, $full_url);
|
||||
curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($this->curl, CURLOPT_USERAGENT, self::USER_AGENT);
|
||||
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($this->curl, CURLOPT_TIMEOUT, 0);
|
||||
|
||||
$res = curl_exec($this->curl);
|
||||
error_log($res);
|
||||
}
|
||||
|
||||
public function post($url, $params = [])
|
||||
{
|
||||
curl_reset($this->curl);
|
||||
|
||||
$date_string = $this->getDateString();
|
||||
$headers = $this->generateHeaders('POST', $url, $date_string);
|
||||
|
||||
// build query string
|
||||
$query_string = http_build_query($params);
|
||||
|
||||
// build url
|
||||
if ($this->port == null)
|
||||
$full_url = $this->protocol . '://' . $this->server . $url;
|
||||
else
|
||||
$full_url = $this->protocol . '://' . $this->server . ':' . $this->port . $url;
|
||||
|
||||
error_log($full_url);
|
||||
|
||||
// curl
|
||||
// curl_setopt($this->curl, CURLOPT_VERBOSE, true);
|
||||
curl_setopt($this->curl, CURLOPT_URL, $full_url);
|
||||
curl_setopt($this->curl, CURLOPT_POST, true);
|
||||
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $query_string);
|
||||
curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($this->curl, CURLOPT_USERAGENT, self::USER_AGENT);
|
||||
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($this->curl, CURLOPT_TIMEOUT, 0);
|
||||
|
||||
$res = curl_exec($this->curl);
|
||||
error_log($res);
|
||||
}
|
||||
|
||||
protected function generateSignature($method, $url, $date_string)
|
||||
{
|
||||
$creds = [
|
||||
$method,
|
||||
$url,
|
||||
$date_string,
|
||||
$this->secret_key,
|
||||
];
|
||||
$sig_source = implode('|', $creds);
|
||||
|
||||
error_log('SIG SOURCE - ' . $sig_source);
|
||||
|
||||
$raw_sig = hash_hmac('sha1', $sig_source, $this->secret_key, true);
|
||||
$enc_sig = base64_encode($raw_sig);
|
||||
|
||||
return $enc_sig;
|
||||
}
|
||||
|
||||
protected function generateHeaders($method, $url, $date_string)
|
||||
{
|
||||
$sig = $this->generateSignature($method, $url, $date_string);
|
||||
|
||||
$headers = [
|
||||
self::HEADER_API_KEY . ': ' . $this->api_key,
|
||||
self::HEADER_SIGNATURE . ': ' . $sig,
|
||||
self::HEADER_DATE . ': ' . $date_string,
|
||||
];
|
||||
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
abstract class APIController extends Controller
|
||||
{
|
||||
protected function checkRequiredParameters(Request $req, $params = [])
|
||||
{
|
||||
$missing = [];
|
||||
|
||||
// check if parameters are there
|
||||
foreach ($params as $param)
|
||||
{
|
||||
if ($req->getMethod() == 'GET')
|
||||
{
|
||||
$check = $req->query->get($param);
|
||||
if (empty($check))
|
||||
$missing[] = $param;
|
||||
}
|
||||
// else if ($req->getMethod() == 'POST')
|
||||
else
|
||||
{
|
||||
$check = $req->request->get($param);
|
||||
//if (empty($check))
|
||||
if (!isset($check))
|
||||
$missing[] = $param;
|
||||
}
|
||||
}
|
||||
|
||||
// check missing parameters
|
||||
if (count($missing) > 0)
|
||||
{
|
||||
$miss_string = implode(', ', $missing);
|
||||
return 'Missing required parameter(s): ' . $miss_string;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\DataFixtures;
|
||||
|
||||
use Catalyst\APIBundle\Entity\Role;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
|
||||
class APIRoleFixtures extends Fixture
|
||||
{
|
||||
public function load(ObjectManager $em)
|
||||
{
|
||||
// setup super user account
|
||||
$role = new Role();
|
||||
$role->setID(Role::SUPER_ADMIN)
|
||||
->setName('Super Administrator');
|
||||
$em->persist($role);
|
||||
$em->flush();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Entity;
|
||||
|
||||
use Catalyst\AuthBundle\Entity\Role as BaseRole;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="api_role")
|
||||
* @UniqueEntity("id")
|
||||
* @UniqueEntity("name")
|
||||
*/
|
||||
class Role extends BaseRole
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="User", mappedBy="roles", fetch="EXTRA_LAZY")
|
||||
*/
|
||||
protected $users;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,186 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Entity;
|
||||
|
||||
use Catalyst\AuthBundle\Entity\User as BaseUser;
|
||||
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\ORM\Mapping\JoinColumn;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use DateTime;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="api_user")
|
||||
*/
|
||||
class User extends BaseUser
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
// api key
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32)
|
||||
*/
|
||||
protected $api_key;
|
||||
|
||||
// secret key
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32)
|
||||
*/
|
||||
protected $secret_key;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=80)
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
// date created
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
protected $date_create;
|
||||
|
||||
// roles
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Role", inversedBy="users")
|
||||
* @ORM\JoinTable(name="api_user_role")
|
||||
*/
|
||||
protected $roles;
|
||||
|
||||
// rider linked to user
|
||||
// NOTE: we're directly linking this only because we don't have to care about other apps using this library
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity="App\Entity\Rider", mappedBy="api_user")
|
||||
*/
|
||||
protected $rider;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
protected $metadata;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// generate keys
|
||||
$this->setAPIKey($this->generateAPIKey())
|
||||
->setSecretKey($this->generateSecretKey());
|
||||
|
||||
// set date created
|
||||
$this->date_create = new DateTime();
|
||||
$this->metadata = [];
|
||||
}
|
||||
|
||||
public function getID()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setAPIKey($api_key)
|
||||
{
|
||||
$this->api_key = $api_key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAPIKey()
|
||||
{
|
||||
return $this->api_key;
|
||||
}
|
||||
|
||||
public function setSecretKey($key)
|
||||
{
|
||||
$this->secret_key = $key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSecretKey()
|
||||
{
|
||||
return $this->secret_key;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getDateCreate()
|
||||
{
|
||||
return $this->date_create;
|
||||
}
|
||||
|
||||
public function getPassword()
|
||||
{
|
||||
// we don't need this for API
|
||||
return 'notneeded';
|
||||
}
|
||||
|
||||
public function getSalt()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getUsername()
|
||||
{
|
||||
// since it's an api, the api key IS the username
|
||||
return $this->api_key;
|
||||
}
|
||||
|
||||
public function eraseCredentials()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public function generateAPIKey()
|
||||
{
|
||||
return $this->generateKey('api');
|
||||
}
|
||||
|
||||
public function generateSecretKey()
|
||||
{
|
||||
return $this->generateKey('secret');
|
||||
}
|
||||
|
||||
public function setMetadata($meta)
|
||||
{
|
||||
$this->metadata = $meta;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMetadata()
|
||||
{
|
||||
if ($this->metadata == null)
|
||||
return [];
|
||||
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
protected function generateKey($prefix = '')
|
||||
{
|
||||
return md5(uniqid($prefix, true));
|
||||
}
|
||||
|
||||
public function setRider($rider)
|
||||
{
|
||||
$this->rider = $rider;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRider()
|
||||
{
|
||||
return $this->rider;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Response;
|
||||
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
class APIResponse extends JsonResponse
|
||||
{
|
||||
public function __construct($success = true, $message = '', $data = null, $status = 200, $headers = [])
|
||||
{
|
||||
$data = [
|
||||
'success' => (bool) $success,
|
||||
'message' => (string) $message,
|
||||
'data' => $data,
|
||||
];
|
||||
parent::__construct($data, $status, $headers);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,160 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Security;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
|
||||
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||
use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface;
|
||||
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class APIKeyAuthenticator implements SimplePreAuthenticatorInterface, AuthenticationFailureHandlerInterface
|
||||
{
|
||||
const HEADER_API_KEY = 'X-Cata-API-Key';
|
||||
const HEADER_SIGNATURE = 'X-Cata-Signature';
|
||||
const HEADER_DATE = 'X-Cata-Date';
|
||||
|
||||
const DATE_FORMAT = 'D, d M Y H:i:s T';
|
||||
|
||||
// 30 minute time limit
|
||||
const TIME_LIMIT = 1800;
|
||||
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
protected function validateSignature($creds, $secret_key)
|
||||
{
|
||||
$elements = [
|
||||
$creds['method'],
|
||||
$creds['uri'],
|
||||
$creds['date'],
|
||||
$secret_key,
|
||||
];
|
||||
$sig_source = implode('|', $elements);
|
||||
|
||||
error_log($sig_source);
|
||||
|
||||
// generate signature
|
||||
$raw_sig = hash_hmac('sha1', $sig_source, $secret_key, true);
|
||||
$enc_sig = base64_encode($raw_sig);
|
||||
|
||||
error_log($enc_sig);
|
||||
|
||||
if ($enc_sig != trim($creds['signature']))
|
||||
throw new CustomUserMessageAuthenticationException('Invalid signature.');
|
||||
|
||||
}
|
||||
|
||||
public function createToken(Request $req, $provider_key)
|
||||
{
|
||||
// api key header
|
||||
$api_key = $req->headers->get(self::HEADER_API_KEY);
|
||||
if ($api_key == null)
|
||||
throw new BadCredentialsException('No API key sent.');
|
||||
|
||||
// check date from headers
|
||||
$hdate_string = $req->headers->get(self::HEADER_DATE);
|
||||
if ($hdate_string == null)
|
||||
throw new BadCredentialsException('No date specified.');
|
||||
|
||||
$hdate = DateTime::createFromFormat(self::DATE_FORMAT, $hdate_string);
|
||||
if ($hdate == null)
|
||||
throw new BadCredentialsException('Invalid date specified.');
|
||||
|
||||
// get number of seconds difference
|
||||
$date_now = new DateTime();
|
||||
$date_diff = abs($date_now->getTimestamp() - $hdate->getTimestamp());
|
||||
|
||||
// time difference is too much
|
||||
if ($date_diff > self::TIME_LIMIT)
|
||||
throw new BadCredentialsException('Clock synchronization error.');
|
||||
|
||||
// signature header
|
||||
$sig = $req->headers->get(self::HEADER_SIGNATURE);
|
||||
if ($sig == null)
|
||||
throw new BadCredentialsException('No signature sent.');
|
||||
|
||||
// credentials
|
||||
$creds = [
|
||||
'api_key' => $api_key,
|
||||
'date' => $hdate_string,
|
||||
'signature' => $sig,
|
||||
'method' => $req->getRealMethod(),
|
||||
'uri' => $req->getPathInfo(),
|
||||
];
|
||||
|
||||
return new PreAuthenticatedToken(
|
||||
'anonymous',
|
||||
$creds,
|
||||
$provider_key
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsToken(TokenInterface $token, $provider_key)
|
||||
{
|
||||
return $token instanceof PreAuthenticatedToken && $token->getProviderKey() === $provider_key;
|
||||
}
|
||||
|
||||
public function authenticateToken(TokenInterface $token, UserProviderInterface $user_provider, $provider_key)
|
||||
{
|
||||
if (!$user_provider instanceof APIKeyUserProvider)
|
||||
{
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
'The user provider must be an instance of APIKeyUserProvider (%s was given).',
|
||||
get_class($user_provider)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$creds = $token->getCredentials();
|
||||
$api_key = $creds['api_key'];
|
||||
$user = $user_provider->getUserByAPIKey($api_key);
|
||||
|
||||
// check if api key is valid
|
||||
if (!$user)
|
||||
throw new CustomUserMessageAuthenticationException('Invalid API Key');
|
||||
|
||||
// check if signature is valid
|
||||
$this->validateSignature($creds, $user->getSecretKey());
|
||||
|
||||
// check if user is enabled
|
||||
if (!$user->isEnabled())
|
||||
{
|
||||
throw new CustomUserMessageAuthenticationException('User account is disabled');
|
||||
}
|
||||
|
||||
// $user = $user_provider->loadUserByUsername($username);
|
||||
|
||||
return new PreAuthenticatedToken(
|
||||
$user,
|
||||
$api_key,
|
||||
$provider_key,
|
||||
$user->getRoles()
|
||||
);
|
||||
}
|
||||
|
||||
public function onAuthenticationFailure(Request $req, AuthenticationException $exception)
|
||||
{
|
||||
$data = [
|
||||
'success' => false,
|
||||
'error' => [
|
||||
'message' => $exception->getMessage(),
|
||||
],
|
||||
];
|
||||
return new JsonResponse($data, 401);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Security;
|
||||
|
||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Catalyst\APIBundle\Entity\User;
|
||||
|
||||
class APIKeyUserProvider implements UserProviderInterface
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function getUserByAPIKey($api_key)
|
||||
{
|
||||
$user = $this->em->getRepository(User::class)->findOneBy(array('api_key' => $api_key));
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function getUsernameForAPIKey($apiKey)
|
||||
{
|
||||
// Look up the username based on the token in the database, via
|
||||
// an API call, or do something entirely different
|
||||
$username = 'test';
|
||||
|
||||
return $username;
|
||||
}
|
||||
|
||||
public function loadUserByUsername($username)
|
||||
{
|
||||
return new User(
|
||||
$username,
|
||||
null,
|
||||
// the roles for the user - you may choose to determine
|
||||
// these dynamically somehow based on the user
|
||||
array('ROLE_API')
|
||||
);
|
||||
}
|
||||
|
||||
public function refreshUser(UserInterface $user)
|
||||
{
|
||||
// this is used for storing authentication in the session
|
||||
// but in this example, the token is sent in each request,
|
||||
// so authentication can be stateless. Throwing this exception
|
||||
// is proper to make things stateless
|
||||
throw new UnsupportedUserException();
|
||||
}
|
||||
|
||||
public function supportsClass($class)
|
||||
{
|
||||
return User::class === $class;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Catalyst\APIBundle\Service;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||
use Symfony\Component\Security\Http\Authorization\AccessDeniedHandlerInterface;
|
||||
|
||||
class AccessDeniedHandler implements AccessDeniedHandlerInterface
|
||||
{
|
||||
public function handle(Request $req, AccessDeniedException $exception)
|
||||
{
|
||||
$content = $exception->getMessage();
|
||||
|
||||
return new Response($content, 403);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,18 +2,43 @@
|
|||
"type": "project",
|
||||
"license": "proprietary",
|
||||
"repositories": [
|
||||
{ "type": "vcs", "url": "git@gitlab.com:jankstudio-catalyst/auth-bundle.git" },
|
||||
{ "type": "vcs", "url": "git@gitlab.com:jankstudio-catalyst/menu-bundle.git" }
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/jankstudio/doctrine2-spatial.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "git@gitlab.com:jankstudio1/catalyst-2/api-bundle.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "git@gitlab.com:jankstudio1/catalyst-2/auth-bundle.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "git@gitlab.com:jankstudio1/catalyst-2/menu-bundle.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://github.com/arcticzero/php-fcm.git"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-iconv": "*",
|
||||
"catalyst/auth-bundle": "dev-master",
|
||||
"catalyst/menu-bundle": "dev-master",
|
||||
"creof/doctrine2-spatial": "^1.2",
|
||||
"composer/package-versions-deprecated": "1.11.99.4",
|
||||
"data-dog/audit-bundle": "^0.1.10",
|
||||
"edwinhoksberg/php-fcm": "^1.0",
|
||||
"doctrine/common": "^2",
|
||||
"doctrine/doctrine-bundle": "^2",
|
||||
"doctrine/doctrine-migrations-bundle": "^2",
|
||||
"doctrine/orm": "^2",
|
||||
"edwinhoksberg/php-fcm": "dev-notif-priority-hotfix",
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"hashids/hashids": "^4.1",
|
||||
"jankstudio/catalyst-api-bundle": "dev-master",
|
||||
"jankstudio/catalyst-auth-bundle": "dev-master",
|
||||
"jankstudio/catalyst-menu-bundle": "dev-master",
|
||||
"jankstudio/doctrine-spatial": "dev-master",
|
||||
"microsoft/azure-storage-blob": "^1.5",
|
||||
"predis/predis": "^1.1",
|
||||
"sensio/framework-extra-bundle": "^5.1",
|
||||
|
|
@ -26,9 +51,7 @@
|
|||
"symfony/framework-bundle": "^4.0",
|
||||
"symfony/maker-bundle": "^1.0",
|
||||
"symfony/monolog-bundle": "^3.7",
|
||||
"symfony/orm-pack": "^1.0",
|
||||
"symfony/process": "^4.0",
|
||||
"symfony/profiler-pack": "^1.0",
|
||||
"symfony/security-bundle": "^4.0",
|
||||
"symfony/translation": "^4.0",
|
||||
"symfony/twig-bundle": "^4.0",
|
||||
|
|
@ -38,18 +61,24 @@
|
|||
"require-dev": {
|
||||
"doctrine/doctrine-fixtures-bundle": "^3.0",
|
||||
"symfony/dotenv": "^4.0",
|
||||
"symfony/thanks": "^1.0"
|
||||
"symfony/stopwatch": "^4.0",
|
||||
"symfony/thanks": "^1.0",
|
||||
"symfony/web-profiler-bundle": "^4.0"
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": {
|
||||
"*": "dist"
|
||||
},
|
||||
"sort-packages": true
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"composer/package-versions-deprecated": true,
|
||||
"symfony/flex": true,
|
||||
"symfony/thanks": true
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "src/",
|
||||
"Catalyst\\APIBundle\\": "catalyst/api-bundle/"
|
||||
"App\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
|
|
|
|||
2083
composer.lock
generated
|
|
@ -272,6 +272,8 @@ access_keys:
|
|||
label: Hub View
|
||||
- id: jo_cancel.fulfill
|
||||
label: Fulfill Cancelled JO
|
||||
- id: jo_resq_proc.list
|
||||
label: RESQ Dispatch
|
||||
|
||||
- id: support
|
||||
label: Customer Support Access
|
||||
|
|
@ -346,6 +348,10 @@ access_keys:
|
|||
label: Customer Source Report
|
||||
- id: report.hub.filter
|
||||
label: Hub Filter Report
|
||||
- id: report.warranty.raffle
|
||||
label: Warranty Raffle Report
|
||||
- id: report.jo.raffle
|
||||
label: JO Raffle Report
|
||||
|
||||
- id: service
|
||||
label: Other Services
|
||||
|
|
@ -518,3 +524,79 @@ access_keys:
|
|||
label: Update
|
||||
- id: dealer.delete
|
||||
label: Delete
|
||||
|
||||
- id: database
|
||||
label: Database Access
|
||||
acls:
|
||||
- id: database.menu
|
||||
label: Menu
|
||||
|
||||
- id: ticket_type
|
||||
label: Ticket Type Access
|
||||
acls:
|
||||
- id: ticket_type.menu
|
||||
label: Menu
|
||||
- id: ticket_type.list
|
||||
label: List
|
||||
- id: ticket_type.add
|
||||
label: Add
|
||||
- id: ticket_type.update
|
||||
label: Update
|
||||
- id: ticket_type.delete
|
||||
label: Delete
|
||||
|
||||
- id: subticket_type
|
||||
label: Sub Ticket Type Access
|
||||
acls:
|
||||
- id: subticket_type.menu
|
||||
label: Menu
|
||||
- id: subticket_type.list
|
||||
label: List
|
||||
- id: subticket_type.add
|
||||
label: Add
|
||||
- id: subticket_type.update
|
||||
label: Update
|
||||
- id: subticket_type.delete
|
||||
label: Delete
|
||||
|
||||
- id: emergency_type
|
||||
label: Emergency Type Access
|
||||
acls:
|
||||
- id: emergency_type.menu
|
||||
label: Menu
|
||||
- id: emergency_type.list
|
||||
label: List
|
||||
- id: emergency_type.add
|
||||
label: Add
|
||||
- id: emergency_type.update
|
||||
label: Update
|
||||
- id: emergency_type.delete
|
||||
label: Delete
|
||||
|
||||
- id: ownership_type
|
||||
label: Ownership Type Access
|
||||
acls:
|
||||
- id: ownership_type.menu
|
||||
label: Menu
|
||||
- id: ownership_type.list
|
||||
label: List
|
||||
- id: ownership_type.add
|
||||
label: Add
|
||||
- id: ownership_type.update
|
||||
label: Update
|
||||
- id: ownership_type.delete
|
||||
label: Delete
|
||||
|
||||
- id: customer_location
|
||||
label: Customer Location Access
|
||||
acls:
|
||||
- id: cust_location.menu
|
||||
label: Menu
|
||||
- id: cust_location.list
|
||||
label: List
|
||||
- id: cust_location.add
|
||||
label: Add
|
||||
- id: cust_location.update
|
||||
label: Update
|
||||
- id: cust_location.delete
|
||||
label: Delete
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ access_keys:
|
|||
acls:
|
||||
- id: customer.register
|
||||
label: Register Customer
|
||||
- id: customer.verify
|
||||
label: Verify Customer
|
||||
- id: municipality
|
||||
label: Municipality
|
||||
acls:
|
||||
|
|
@ -67,3 +69,56 @@ access_keys:
|
|||
acls:
|
||||
- id: dealer.list
|
||||
label: List
|
||||
- id: warrantyserial
|
||||
label: Warranty Serial
|
||||
acls:
|
||||
- id: warrantyserial.upload
|
||||
label: Upload
|
||||
|
||||
- id: tapi_vmanufacturer
|
||||
label: Third Party Vehicle Manufacturer Access
|
||||
acls:
|
||||
- id: tapi_vmanufacturer.list
|
||||
label: List Third Party Vehicle Manufacturers
|
||||
- id: tapi_vehicle
|
||||
label: Third Party Vehicle Make Access
|
||||
acls:
|
||||
- id: tapi_vehicle.list
|
||||
label: List Third Party Vehicles
|
||||
- id: tapi_promo
|
||||
label: Third Party Promo Access
|
||||
acls:
|
||||
- id: tapi_promo.list
|
||||
label: List Third Party Promos
|
||||
- id: tapi_battery
|
||||
label: Third Party Battery Access
|
||||
acls:
|
||||
- id: tapi_battery_compatible.list
|
||||
label: List Third Party Compatible Batteries
|
||||
- id: tapi_jo
|
||||
label: Third Party Job Order Access
|
||||
acls:
|
||||
- id: tapi_jo.request
|
||||
label: Third Party Request Job Order
|
||||
- id: tapi_jo.get.estimate
|
||||
label: Third Party Get Estimate
|
||||
- id: tapi_jo.get.ongoing
|
||||
label: Third Party Get Ongoing Job Order
|
||||
- id: tapi_jo.cancel
|
||||
label: Third Party Cancel Job Order
|
||||
- id: tapi_jo.get.invoice
|
||||
label: Third Party Get Job Order Invoice
|
||||
- id: tapi_jo.location.support
|
||||
label: Third Party Check Location Support
|
||||
- id: tapi_jo.nearest_hub.get
|
||||
label: Third Party Get Nearest Hub and Slots
|
||||
- id: tapi_jo.schedule_option.status
|
||||
label: Third Party Schedule Option Status
|
||||
- id: tapi_jo.get.info
|
||||
label: Third Party Get Job Order Info
|
||||
- id: tapi_service
|
||||
label: Third Party Service Access
|
||||
acls:
|
||||
- id: tapi_service.list
|
||||
label: List Third Party Services
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
return [
|
||||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
|
||||
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
|
||||
|
|
@ -11,8 +10,8 @@ return [
|
|||
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
|
||||
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
|
||||
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
||||
Catalyst\APIBundle\CatalystAPIBundle::class => ['all' => true],
|
||||
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
||||
Catalyst\ApiBundle\CatalystApiBundle::class => ['all' => true],
|
||||
Catalyst\AuthBundle\CatalystAuthBundle::class => ['all' => true],
|
||||
Catalyst\MenuBundle\CatalystMenuBundle::class => ['all' => true],
|
||||
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
||||
];
|
||||
|
|
|
|||
|
|
@ -42,20 +42,6 @@ services:
|
|||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
|
||||
Catalyst\AuthBundle\Service\ACLGenerator:
|
||||
arguments:
|
||||
$router: "@router.default"
|
||||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
$acl_file: "%app_acl_file%"
|
||||
|
||||
Catalyst\AuthBundle\Service\ACLVoter:
|
||||
arguments:
|
||||
$user_class: "App\\Entity\\User"
|
||||
tags: ['security.voter']
|
||||
|
||||
Catalyst\AuthBundle\Service\UserChecker:
|
||||
|
||||
App\Service\FileUploader:
|
||||
arguments:
|
||||
$target_dir: '%image_upload_directory%'
|
||||
|
|
@ -114,50 +100,6 @@ services:
|
|||
arguments:
|
||||
$redis_client: "@App\\Service\\RedisClientProvider"
|
||||
|
||||
Catalyst\APIBundle\Security\APIKeyUserProvider:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
Catalyst\APIBundle\Security\APIKeyAuthenticator:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
Catalyst\APIBundle\Command\UserCreateCommand:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
tags: ['console.command']
|
||||
|
||||
Catalyst\APIBundle\Command\TestCommand:
|
||||
tags: ['console.command']
|
||||
|
||||
Catalyst\APIBundle\Command\TestAPICommand:
|
||||
tags: ['console.command']
|
||||
|
||||
Catalyst\APIBundle\Access\Voter:
|
||||
arguments:
|
||||
$acl_gen: "@Catalyst\\APIBundle\\Access\\Generator"
|
||||
$user_class: "Catalyst\\APIBundle\\Entity\\User"
|
||||
tags: ['security.voter']
|
||||
|
||||
Catalyst\APIBundle\Access\Generator:
|
||||
arguments:
|
||||
$router: "@router.default"
|
||||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
$acl_file: "%api_acl_file%"
|
||||
|
||||
Catalyst\MenuBundle\Menu\Generator:
|
||||
arguments:
|
||||
$router: "@router.default"
|
||||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
|
||||
Catalyst\MenuBundle\Listener\MenuAnnotationListener:
|
||||
arguments:
|
||||
$menu_name: "main_menu"
|
||||
tags:
|
||||
- { name: kernel.event_listener, event: kernel.controller, method: onKernelController }
|
||||
|
||||
# invoice generator
|
||||
App\Service\InvoiceGenerator\CMBInvoiceGenerator: ~
|
||||
|
||||
|
|
|
|||
|
|
@ -132,6 +132,10 @@ main_menu:
|
|||
acl: jo_proc.list
|
||||
label: Dispatch
|
||||
parent: joborder
|
||||
- id: jo_resq_proc
|
||||
acl: jo_resq_proc.list
|
||||
label: RESQ Dispatch
|
||||
parent: joborder
|
||||
- id: jo_assign
|
||||
acl: jo_assign.list
|
||||
label: Rider Assignment
|
||||
|
|
@ -224,3 +228,28 @@ main_menu:
|
|||
acl: analytics.forecast
|
||||
label: Forecasting
|
||||
parent: analytics
|
||||
|
||||
- id: database
|
||||
acl: database.menu
|
||||
label: Database
|
||||
icon: fa fa-database
|
||||
- id: ticket_type_list
|
||||
acl: ticket_type.menu
|
||||
label: Ticket Types
|
||||
parent: database
|
||||
- id: subticket_type_list
|
||||
acl: subticket_type.menu
|
||||
label: Sub Ticket Types
|
||||
parent: database
|
||||
- id: emergency_type_list
|
||||
acl: emergency_type.menu
|
||||
label: Emergency Types
|
||||
parent: database
|
||||
- id: ownership_type_list
|
||||
acl: ownership_type.menu
|
||||
label: Ownership Types
|
||||
parent: database
|
||||
- id: customer_location_list
|
||||
acl: cust_location.menu
|
||||
label: Customer Locations
|
||||
parent: database
|
||||
|
|
|
|||
944
config/packages/catalyst_auth.yaml
Normal file
|
|
@ -0,0 +1,944 @@
|
|||
catalyst_auth:
|
||||
main:
|
||||
user_entity: "App\\Entity\\User"
|
||||
acl_data:
|
||||
- id: dashboard
|
||||
label: Dashboard Access
|
||||
acls:
|
||||
- id: dashboard.menu
|
||||
label: Menu
|
||||
- id: user
|
||||
label: User Access
|
||||
acls:
|
||||
- id: user.menu
|
||||
label: Menu
|
||||
- id: user.list
|
||||
label: List
|
||||
- id: user.add
|
||||
label: Add
|
||||
- id: user.update
|
||||
label: Update
|
||||
- id: user.delete
|
||||
label: Delete
|
||||
- id: user.role.sadmin
|
||||
label: Super Admin Role
|
||||
- id: user.profile
|
||||
label: User Profile
|
||||
- id: role
|
||||
label: Role Access
|
||||
acls:
|
||||
- id: role.menu
|
||||
label: Menu
|
||||
- id: role.list
|
||||
label: List
|
||||
- id: role.add
|
||||
label: Add
|
||||
- id: role.update
|
||||
label: Update
|
||||
- id: role.delete
|
||||
label: Delete
|
||||
- id: apiuser
|
||||
label: API User Access
|
||||
acls:
|
||||
- id: apiuser.menu
|
||||
label: Menu
|
||||
- id: apiuser.list
|
||||
label: List
|
||||
- id: apiuser.add
|
||||
label: Add
|
||||
- id: apiuser.update
|
||||
label: Update
|
||||
- id: apiuser.delete
|
||||
label: Delete
|
||||
- id: apirole
|
||||
label: API Role Access
|
||||
acls:
|
||||
- id: apirole.menu
|
||||
label: Menu
|
||||
- id: apirole.list
|
||||
label: List
|
||||
- id: apirole.add
|
||||
label: Add
|
||||
- id: apirole.update
|
||||
label: Update
|
||||
- id: apirole.delete
|
||||
label: Delete
|
||||
- id: logistics
|
||||
label: Logistics Access
|
||||
acls:
|
||||
- id: logistics.menu
|
||||
label: Menu
|
||||
- id: battery
|
||||
label: Battery Access
|
||||
acls:
|
||||
- id: battery.menu
|
||||
label: Menu
|
||||
- id: battery.list
|
||||
label: List
|
||||
- id: battery.add
|
||||
label: Add
|
||||
- id: battery.update
|
||||
label: Update
|
||||
- id: battery.delete
|
||||
label: Delete
|
||||
- id: bmfg
|
||||
label: Battery Manufacturer Access
|
||||
acls:
|
||||
- id: bmfg.menu
|
||||
label: Menu
|
||||
- id: bmfg.list
|
||||
label: List
|
||||
- id: bmfg.add
|
||||
label: Add
|
||||
- id: bmfg.update
|
||||
label: Update
|
||||
- id: bmfg.delete
|
||||
label: Delete
|
||||
- id: bmodel
|
||||
label: Battery Model Access
|
||||
acls:
|
||||
- id: bmodel.menu
|
||||
label: Menu
|
||||
- id: bmodel.list
|
||||
label: List
|
||||
- id: bmodel.add
|
||||
label: Add
|
||||
- id: bmodel.update
|
||||
label: Update
|
||||
- id: bmodel.delete
|
||||
label: Delete
|
||||
- id: bsize
|
||||
label: Battery Size Access
|
||||
acls:
|
||||
- id: bsize.menu
|
||||
label: Menu
|
||||
- id: bsize.list
|
||||
label: List
|
||||
- id: bsize.add
|
||||
label: Add
|
||||
- id: bsize.update
|
||||
label: Update
|
||||
- id: bsize.delete
|
||||
label: Delete
|
||||
- id: vehicle
|
||||
label: Vehicle Access
|
||||
acls:
|
||||
- id: vehicle.menu
|
||||
label: Menu
|
||||
- id: vehicle.list
|
||||
label: List
|
||||
- id: vehicle.add
|
||||
label: Add
|
||||
- id: vehicle.update
|
||||
label: Update
|
||||
- id: vehicle.delete
|
||||
label: Delete
|
||||
- id: vmfg
|
||||
label: Vehicle Manufacturer Access
|
||||
acls:
|
||||
- id: vmfg.menu
|
||||
label: Menu
|
||||
- id: vmfg.list
|
||||
label: List
|
||||
- id: vmfg.add
|
||||
label: Add
|
||||
- id: vmfg.update
|
||||
label: Update
|
||||
- id: vmfg.delete
|
||||
label: Delete
|
||||
- id: customer
|
||||
label: Customer Access
|
||||
acls:
|
||||
- id: customer.menu
|
||||
label: Menu
|
||||
- id: customer.list
|
||||
label: List
|
||||
- id: customer.add
|
||||
label: Add
|
||||
- id: customer.update
|
||||
label: Update
|
||||
- id: customer.delete
|
||||
label: Delete
|
||||
- id: customer.dpa
|
||||
label: Display DPA
|
||||
|
||||
|
||||
- id: location
|
||||
label: Location Access
|
||||
acls:
|
||||
- id: location.menu
|
||||
label: Menu
|
||||
- id: outlet
|
||||
label: Outlet Access
|
||||
acls:
|
||||
- id: outlet.menu
|
||||
label: Menu
|
||||
- id: outlet.list
|
||||
label: List
|
||||
- id: outlet.add
|
||||
label: Add
|
||||
- id: outlet.update
|
||||
label: Update
|
||||
- id: outlet.delete
|
||||
label: Delete
|
||||
- id: hub
|
||||
label: Hub Access
|
||||
acls:
|
||||
- id: hub.menu
|
||||
label: Menu
|
||||
- id: hub.list
|
||||
label: List
|
||||
- id: hub.add
|
||||
label: Add
|
||||
- id: hub.update
|
||||
label: Update
|
||||
- id: hub.delete
|
||||
label: Delete
|
||||
- id: geofence
|
||||
label: Geofence
|
||||
acls:
|
||||
- id: geofence.menu
|
||||
label: Menu
|
||||
- id: geofence.list
|
||||
label: List
|
||||
- id: geofence.add
|
||||
label: Add
|
||||
- id: geofence.delete
|
||||
label: Delete
|
||||
|
||||
- id: rider
|
||||
label: Rider Access
|
||||
acls:
|
||||
- id: rider.menu
|
||||
label: Menu
|
||||
- id: rider.list
|
||||
label: List
|
||||
- id: rider.add
|
||||
label: Add
|
||||
- id: rider.update
|
||||
label: Update
|
||||
- id: rider.delete
|
||||
label: Delete
|
||||
|
||||
- id: servicecharge
|
||||
label: Service Charge
|
||||
acls:
|
||||
- id: service_charge.menu
|
||||
label: Menu
|
||||
- id: service_charge.list
|
||||
label: List
|
||||
- id: service_charge.add
|
||||
label: Add
|
||||
- id: service_charge.update
|
||||
label: Update
|
||||
- id: service_charge.delete
|
||||
label: Delete
|
||||
|
||||
- id: joborder
|
||||
label: Job Order
|
||||
acls:
|
||||
- id: joborder.menu
|
||||
label: Menu
|
||||
- id: jo_in.list
|
||||
label: Incoming
|
||||
- id: jo_proc.list
|
||||
label: Dispatch
|
||||
- id: jo_proc.unlock
|
||||
label: Dispatch Unlock
|
||||
- id: jo_assign.list
|
||||
label: Rider Assignment
|
||||
- id: jo_assign.unlock
|
||||
label: Rider Assignment Unlock
|
||||
- id: jo_fulfill.list
|
||||
label: Fulfillment
|
||||
- id: jo_open.list
|
||||
label: Open
|
||||
- id: jo_all.list
|
||||
label: View All
|
||||
- id: jo_pdf.list
|
||||
label: PDF
|
||||
- id: jo_open.edit
|
||||
label: Edit
|
||||
- id: joborder.cancel
|
||||
label: Cancel
|
||||
- id: jo_onestep.form
|
||||
label: One-step Process
|
||||
- id: jo_onestep.edit
|
||||
label: One-step Process Edit
|
||||
- id: jo_walkin.form
|
||||
label: Walk-in
|
||||
- id: jo_walkin.edit
|
||||
label: Walk-in Edit
|
||||
- id: jo_autoassign.test
|
||||
label: Autoassign Test
|
||||
- id: jo_hub.list
|
||||
label: Hub View
|
||||
- id: jo_cancel.fulfill
|
||||
label: Fulfill Cancelled JO
|
||||
- id: jo_resq_proc.list
|
||||
label: RESQ Dispatch
|
||||
- id: jo_resq_all.list
|
||||
label: RESQ All
|
||||
|
||||
- id: support
|
||||
label: Customer Support Access
|
||||
acls:
|
||||
- id: support.menu
|
||||
label: Menu
|
||||
- id: general.search
|
||||
label: Search
|
||||
- id: warranty.search
|
||||
label: Customer Battery Search
|
||||
- id: warranty.upload
|
||||
label: Warranty Upload
|
||||
|
||||
- id: ticket
|
||||
label: Ticket Access
|
||||
acls:
|
||||
- id: ticket.menu
|
||||
label: Menu
|
||||
- id: ticket.list
|
||||
label: List
|
||||
- id: ticket.add
|
||||
label: Add
|
||||
- id: ticket.update
|
||||
label: Update
|
||||
- id: ticket.delete
|
||||
label: Delete
|
||||
|
||||
- id: promo
|
||||
label: Promo Access
|
||||
acls:
|
||||
- id: promo.menu
|
||||
label: Menu
|
||||
- id: promo.list
|
||||
label: List
|
||||
- id: promo.add
|
||||
label: Add
|
||||
- id: promo.update
|
||||
label: Update
|
||||
- id: promo.delete
|
||||
label: Delete
|
||||
|
||||
- id: report
|
||||
label: Reports
|
||||
acls:
|
||||
- id: report.menu
|
||||
label: Menu
|
||||
- id: report.reject
|
||||
label: Rejection Report
|
||||
- id: report.battery.conflict
|
||||
label: Battery Conflict Report
|
||||
- id: report.popapp.comparison
|
||||
label: Popapp Comparison Report
|
||||
- id: report.meh.customer
|
||||
label: RESQ MEH Customer Report
|
||||
- id: report.warranty.class
|
||||
label: Warranty Class Report
|
||||
- id: report.vehicle.battery.compatibility
|
||||
label: Vehicle Battery Compatibility Report
|
||||
- id: report.warranty.details
|
||||
label: Warranty Details Report
|
||||
- id: report.jo.details
|
||||
label: Job Order Details Report
|
||||
- id: report.jo_events
|
||||
label: Job Order Events Report
|
||||
- id: report.sms_messages
|
||||
label: SMS Messages Report
|
||||
- id: report.jo.auto_assign
|
||||
label: Auto Assigned Job Order Report
|
||||
- id: report.jo.advance_order
|
||||
label: Advance Order Job Order Report
|
||||
- id: report.customer.source
|
||||
label: Customer Source Report
|
||||
- id: report.hub.filter
|
||||
label: Hub Filter Report
|
||||
- id: report.warranty.raffle
|
||||
label: Warranty Raffle Report
|
||||
- id: report.jo.raffle
|
||||
label: JO Raffle Report
|
||||
|
||||
- id: service
|
||||
label: Other Services
|
||||
acls:
|
||||
- id: service.menu
|
||||
label: Menu
|
||||
- id: service.list
|
||||
label: List
|
||||
- id: service.add
|
||||
label: Add
|
||||
- id: service.update
|
||||
label: Update
|
||||
- id: service.delete
|
||||
label: Delete
|
||||
|
||||
- id: partner
|
||||
label: Partners
|
||||
acls:
|
||||
- id: partner.menu
|
||||
label: Menu
|
||||
- id: partner.list
|
||||
label: List
|
||||
- id: partner.add
|
||||
label: Add
|
||||
- id: partner.update
|
||||
label: Update
|
||||
- id: partner.delete
|
||||
label: Delete
|
||||
|
||||
- id: motolite_event
|
||||
label: Motolite Events
|
||||
acls:
|
||||
- id: motolite_event.menu
|
||||
label: Menu
|
||||
- id: motolite_event.list
|
||||
label: List
|
||||
- id: motolite_event.add
|
||||
label: Add
|
||||
- id: motolite_event.update
|
||||
label: Update
|
||||
- id: motolite_event.delete
|
||||
label: Delete
|
||||
|
||||
- id: review
|
||||
label: Reviews
|
||||
acls:
|
||||
- id: review.menu
|
||||
label: Menu
|
||||
- id: review.list
|
||||
label: List
|
||||
- id: review.view
|
||||
label: View
|
||||
- id: review.delete
|
||||
label: Delete
|
||||
|
||||
- id: privacypolicy
|
||||
label: Privacy Policy
|
||||
acls:
|
||||
- id: privacy_policy.menu
|
||||
label: Menu
|
||||
- id: privacy_policy.list
|
||||
label: List
|
||||
- id: privacy_policy.add
|
||||
label: Add
|
||||
- id: privacy_policy.update
|
||||
label: Update
|
||||
- id: privacy_policy.delete
|
||||
label: Delete
|
||||
|
||||
- id: warranty
|
||||
label: Warranty
|
||||
acls:
|
||||
- id: warranty.menu
|
||||
label: Menu
|
||||
- id: warranty.list
|
||||
label: List
|
||||
- id: warranty.add
|
||||
label: Add
|
||||
- id: warranty.update
|
||||
label: Update
|
||||
|
||||
- id: staticcontent
|
||||
label: Static Content
|
||||
acls:
|
||||
- id: static_content.menu
|
||||
label: Menu
|
||||
- id: static_content.list
|
||||
label: List
|
||||
- id: static_content.add
|
||||
label: Add
|
||||
- id: static_content.update
|
||||
label: Update
|
||||
- id: static_content.delete
|
||||
label: Delete
|
||||
|
||||
- id: analytics
|
||||
label: Analytics
|
||||
acls:
|
||||
- id: analytics.menu
|
||||
label: Menu
|
||||
- id: analytics.forecast
|
||||
label: Forecasting
|
||||
|
||||
- id: sap_battery
|
||||
label: SAP Battery Access
|
||||
acls:
|
||||
- id: sap_battery.menu
|
||||
label: Menu
|
||||
- id: sap_battery.list
|
||||
label: List
|
||||
- id: sap_battery.add
|
||||
label: Add
|
||||
- id: sap_battery.update
|
||||
label: Update
|
||||
- id: sap_battery.delete
|
||||
label: Delete
|
||||
|
||||
- id: sap_brand
|
||||
label: SAP Battery Brand Access
|
||||
acls:
|
||||
- id: sap_brand.menu
|
||||
label: Menu
|
||||
- id: sap_brand.list
|
||||
label: List
|
||||
- id: sap_brand.add
|
||||
label: Add
|
||||
- id: sap_brand.update
|
||||
label: Update
|
||||
- id: sap_brand.delete
|
||||
label: Delete
|
||||
|
||||
- id: sap_bsize
|
||||
label: SAP Battery Size Access
|
||||
acls:
|
||||
- id: sap_bsize.menu
|
||||
label: Menu
|
||||
- id: sap_bsize.list
|
||||
label: List
|
||||
- id: sap_bsize.add
|
||||
label: Add
|
||||
- id: sap_bsize.update
|
||||
label: Update
|
||||
- id: sap_bsize.delete
|
||||
label: Delete
|
||||
|
||||
- id: sap_csize
|
||||
label: SAP Battery Container Size Access
|
||||
acls:
|
||||
- id: sap_csize.menu
|
||||
label: Menu
|
||||
- id: sap_csize.list
|
||||
label: List
|
||||
- id: sap_csize.add
|
||||
label: Add
|
||||
- id: sap_csize.update
|
||||
label: Update
|
||||
- id: sap_csize.delete
|
||||
label: Delete
|
||||
|
||||
- id: customer_tag
|
||||
label: Customer Tags Access
|
||||
acls:
|
||||
- id: customer_tag.menu
|
||||
label: Menu
|
||||
- id: customer_tag.list
|
||||
label: List
|
||||
- id: customer_tag.add
|
||||
label: Add
|
||||
- id: customer_tag.update
|
||||
label: Update
|
||||
- id: customer_tag.delete
|
||||
label: Delete
|
||||
|
||||
- id: review_tag
|
||||
label: Review Tags Access
|
||||
acls:
|
||||
- id: review_tag.menu
|
||||
label: Menu
|
||||
- id: review_tag.list
|
||||
label: List
|
||||
- id: review_tag.add
|
||||
label: Add
|
||||
- id: review_tag.update
|
||||
label: Update
|
||||
- id: review_tag.delete
|
||||
label: Delete
|
||||
|
||||
- id: dealer
|
||||
label: Dealer Access
|
||||
acls:
|
||||
- id: dealer.menu
|
||||
label: Menu
|
||||
- id: dealer.list
|
||||
label: List
|
||||
- id: dealer.add
|
||||
label: Add
|
||||
- id: dealer.update
|
||||
label: Update
|
||||
- id: dealer.delete
|
||||
label: Delete
|
||||
|
||||
- id: database
|
||||
label: Database Access
|
||||
acls:
|
||||
- id: database.menu
|
||||
label: Menu
|
||||
|
||||
- id: ticket_type
|
||||
label: Ticket Type Access
|
||||
acls:
|
||||
- id: ticket_type.menu
|
||||
label: Menu
|
||||
- id: ticket_type.list
|
||||
label: List
|
||||
- id: ticket_type.add
|
||||
label: Add
|
||||
- id: ticket_type.update
|
||||
label: Update
|
||||
- id: ticket_type.delete
|
||||
label: Delete
|
||||
|
||||
- id: subticket_type
|
||||
label: Sub Ticket Type Access
|
||||
acls:
|
||||
- id: subticket_type.menu
|
||||
label: Menu
|
||||
- id: subticket_type.list
|
||||
label: List
|
||||
- id: subticket_type.add
|
||||
label: Add
|
||||
- id: subticket_type.update
|
||||
label: Update
|
||||
- id: subticket_type.delete
|
||||
label: Delete
|
||||
|
||||
- id: emergency_type
|
||||
label: Emergency Type Access
|
||||
acls:
|
||||
- id: emergency_type.menu
|
||||
label: Menu
|
||||
- id: emergency_type.list
|
||||
label: List
|
||||
- id: emergency_type.add
|
||||
label: Add
|
||||
- id: emergency_type.update
|
||||
label: Update
|
||||
- id: emergency_type.delete
|
||||
label: Delete
|
||||
|
||||
- id: ownership_type
|
||||
label: Ownership Type Access
|
||||
acls:
|
||||
- id: ownership_type.menu
|
||||
label: Menu
|
||||
- id: ownership_type.list
|
||||
label: List
|
||||
- id: ownership_type.add
|
||||
label: Add
|
||||
- id: ownership_type.update
|
||||
label: Update
|
||||
- id: ownership_type.delete
|
||||
label: Delete
|
||||
|
||||
- id: service_offering
|
||||
label: Service Offering Access
|
||||
acls:
|
||||
- id: service_offering.menu
|
||||
label: Menu
|
||||
- id: service_offering.list
|
||||
label: List
|
||||
- id: service_offering.add
|
||||
label: Add
|
||||
- id: service_offering.update
|
||||
label: Update
|
||||
- id: service_offering.delete
|
||||
label: Delete
|
||||
|
||||
- id: price_tier
|
||||
label: Price Tier
|
||||
acls:
|
||||
- id: price_tier.menu
|
||||
label: Menu
|
||||
- id: price_tier.list
|
||||
label: List
|
||||
- id: price_tier.add
|
||||
label: Add
|
||||
- id: price_tier.update
|
||||
label: Update
|
||||
- id: price_tier.delete
|
||||
label: Delete
|
||||
|
||||
- id: item_type
|
||||
label: Item Type
|
||||
acls:
|
||||
- id: item_type.menu
|
||||
label: Menu
|
||||
- id: item_type.list
|
||||
label: List
|
||||
- id: item_type.add
|
||||
label: Add
|
||||
- id: item_type.update
|
||||
label: Update
|
||||
- id: item_type.delete
|
||||
label: Delete
|
||||
|
||||
- id: item
|
||||
label: Item
|
||||
acls:
|
||||
- id: item.menu
|
||||
label: Menu
|
||||
- id: item_pricing
|
||||
label: Item Pricing
|
||||
acls:
|
||||
- id: item_pricing.update
|
||||
label: Update
|
||||
|
||||
api:
|
||||
user_entity: "App\\Entity\\ApiUser"
|
||||
acl_data:
|
||||
- id: warranty
|
||||
label: Warranty Access
|
||||
acls:
|
||||
- id: warranty.list
|
||||
label: List
|
||||
- id: warranty.find.serial
|
||||
label: Find by Serial
|
||||
- id: warranty.find.platenumber
|
||||
label: Find by Plate Number
|
||||
- id: warranty.register.battery
|
||||
label: Register Battery
|
||||
- id: warranty.claim
|
||||
label: Claim
|
||||
- id: warranty.update
|
||||
label: Update
|
||||
- id: warranty.cancel
|
||||
label: Cancel
|
||||
- id: warranty.delete
|
||||
label: Delete
|
||||
- id: warranty.set.privacypolicy
|
||||
label: Set Privacy Policy
|
||||
- id: warranty.list.serial
|
||||
label: List by Serial
|
||||
- id: batterybrand
|
||||
label: Battery Brand Access
|
||||
acls:
|
||||
- id: batterybrand.list
|
||||
label: List
|
||||
- id: batterysize
|
||||
label: Battery Size Access
|
||||
acls:
|
||||
- id: batterysize.list
|
||||
label: List
|
||||
- id: battery
|
||||
label: Battery Access
|
||||
acls:
|
||||
- id: battery.list
|
||||
label: List
|
||||
- id: vmanufacturer
|
||||
label: Vehicle Manufacturer Access
|
||||
acls:
|
||||
- id: vmanufacturer.list
|
||||
label: List
|
||||
- id: vehicle
|
||||
label: Vehicle Access
|
||||
acls:
|
||||
- id: vehicle.list
|
||||
label: List
|
||||
- id: privacypolicy
|
||||
label: Privacy Policy
|
||||
acls:
|
||||
- id: privacypolicy.find
|
||||
label: Find Privacy Policy
|
||||
- id: customer
|
||||
label: Customer
|
||||
acls:
|
||||
- id: customer.register
|
||||
label: Register Customer
|
||||
- id: customer.verify
|
||||
label: Verify Customer
|
||||
- id: municipality
|
||||
label: Municipality
|
||||
acls:
|
||||
- id: municipality.list
|
||||
label: List
|
||||
- id: dealer
|
||||
label: Dealer
|
||||
acls:
|
||||
- id: dealer.list
|
||||
label: List
|
||||
- id: warrantyserial
|
||||
label: Warranty Serial
|
||||
acls:
|
||||
- id: warrantyserial.upload
|
||||
label: Upload
|
||||
- id: hub
|
||||
label: Hub Access
|
||||
acls:
|
||||
- id: hub.list
|
||||
label: List
|
||||
- id: joborder
|
||||
label: Job Order Access
|
||||
acls:
|
||||
- id: joborder.find
|
||||
label: Find Job Order
|
||||
|
||||
- id: tapi_vmanufacturer
|
||||
label: Third Party Vehicle Manufacturer Access
|
||||
acls:
|
||||
- id: tapi_vmanufacturer.list
|
||||
label: List Third Party Vehicle Manufacturers
|
||||
- id: tapi_vehicle
|
||||
label: Third Party Vehicle Make Access
|
||||
acls:
|
||||
- id: tapi_vehicle.list
|
||||
label: List Third Party Vehicles
|
||||
- id: tapi_promo
|
||||
label: Third Party Promo Access
|
||||
acls:
|
||||
- id: tapi_promo.list
|
||||
label: List Third Party Promos
|
||||
- id: tapi_battery
|
||||
label: Third Party Battery Access
|
||||
acls:
|
||||
- id: tapi_battery_compatible.list
|
||||
label: List Third Party Compatible Batteries
|
||||
- id: tapi_jo
|
||||
label: Third Party Job Order Access
|
||||
acls:
|
||||
- id: tapi_jo.request
|
||||
label: Third Party Request Job Order
|
||||
- id: tapi_jo.get.estimate
|
||||
label: Third Party Get Estimate
|
||||
- id: tapi_jo.get.ongoing
|
||||
label: Third Party Get Ongoing Job Order
|
||||
- id: tapi_jo.cancel
|
||||
label: Third Party Cancel Job Order
|
||||
- id: tapi_jo.get.invoice
|
||||
label: Third Party Get Job Order Invoice
|
||||
- id: tapi_jo.location.support
|
||||
label: Third Party Check Location Support
|
||||
- id: tapi_jo.nearest_hub.get
|
||||
label: Third Party Get Nearest Hub and Slots
|
||||
- id: tapi_jo.schedule_option.status
|
||||
label: Third Party Schedule Option Status
|
||||
- id: tapi_jo.get.info
|
||||
label: Third Party Get Job Order Info
|
||||
- id: tapi_service
|
||||
label: Third Party Service Access
|
||||
acls:
|
||||
- id: tapi_service.list
|
||||
label: List Third Party Services
|
||||
|
||||
cust_api_v2:
|
||||
user_entity: "App\\Entity\\CustomerUser"
|
||||
acl_data:
|
||||
- id: cust_api_v2.auth
|
||||
label: Authentication
|
||||
acls:
|
||||
- id: cust_api_v2.auth.register
|
||||
label: Register
|
||||
- id: cust_api_v2.auth.confirm
|
||||
label: Confirm Number
|
||||
- id: cust_api_v2.auth.validate
|
||||
label: Validate Code
|
||||
- id: cust_api_v2.auth.resend_code
|
||||
label: Resend Code
|
||||
- id: cust_api_v2.customer
|
||||
label: Customer
|
||||
acls:
|
||||
- id: cust_api_v2.customer.info
|
||||
label: Info
|
||||
- id: cust_api_v2.customer.update
|
||||
label: Update
|
||||
- id: cust_api_v2.customer.status
|
||||
label: Status
|
||||
- id: cust_api_v2.customer.hash
|
||||
label: Hash
|
||||
- id: cust_api_v2.device
|
||||
label: Device
|
||||
acls:
|
||||
- id: cust_api_v2.device.id
|
||||
label: Update
|
||||
- id: cust_api_v2.invoice
|
||||
label: Invoice
|
||||
acls:
|
||||
- id: cust_api_v2.invoice.estimate
|
||||
label: Estimate
|
||||
- id: cust_api_v2.jo
|
||||
label: Job Order
|
||||
acls:
|
||||
- id: cust_api_v2.jo.ongoing
|
||||
label: List Ongoing
|
||||
- id: cust_api_v2.jo.invoice
|
||||
label: Get Invoice
|
||||
- id: cust_api_v2.jo.cancel
|
||||
label: Cancel
|
||||
- id: cust_api_v2.jo.info
|
||||
label: Info
|
||||
- id: cust_api_v2.jo.history
|
||||
label: History
|
||||
- id: cust_api_v2.jo.latest
|
||||
label: Latest
|
||||
- id: cust_api_v2.jo.all_ongoing
|
||||
label: List All Ongoing
|
||||
- id: cust_api_v2.jo.ongoing_count
|
||||
label: List Ongoing Count
|
||||
- id: cust_api_v2.jo.create
|
||||
label: Create
|
||||
- id: cust_api_v2.jo.request
|
||||
label: Request
|
||||
- id: cust_api_v2.jo.completed
|
||||
label: List Completed
|
||||
- id: cust_api_v2.location
|
||||
label: Location
|
||||
acls:
|
||||
- id: cust_api_v2.location.support
|
||||
label: Get Support Status
|
||||
- id: cust_api_v2.location.nearest_hub_and_slots
|
||||
label: List Nearest Hub and Slots
|
||||
- id: cust_api_v2.location.create
|
||||
label: Create
|
||||
- id: cust_api_v2.location.list
|
||||
label: List
|
||||
- id: cust_api_v2.partner
|
||||
label: Partner
|
||||
acls:
|
||||
- id: cust_api_v2.partner.info
|
||||
label: Info
|
||||
- id: cust_api_v2.partner.closest
|
||||
label: List Closest Partners
|
||||
- id: cust_api_v2.partner.review
|
||||
label: Review
|
||||
- id: cust_api_v2.privacy
|
||||
label: Privacy
|
||||
acls:
|
||||
- id: cust_api_v2.privacy.settings
|
||||
label: Get Privacy Settings
|
||||
- id: cust_api_v2.promo
|
||||
label: Promo
|
||||
acls:
|
||||
- id: cust_api_v2.promo.list
|
||||
label: Get Promos
|
||||
- id: cust_api_v2.rider
|
||||
label: Rider
|
||||
acls:
|
||||
- id: cust_api_v2.rider.status
|
||||
label: Status
|
||||
- id: cust_api_v2.rider.rating
|
||||
label: Rate
|
||||
- id: cust_api_v2.schedule
|
||||
label: Schedule
|
||||
acls:
|
||||
- id: cust_api_v2.schedule.status
|
||||
label: Get Schedule Option Status
|
||||
- id: cust_api_v2.service
|
||||
label: Service
|
||||
acls:
|
||||
- id: cust_api_v2.service.list
|
||||
label: List
|
||||
- id: cust_api_v2.vehicle
|
||||
label: Vehicle
|
||||
acls:
|
||||
- id: cust_api_v2.vehicle.mfgs
|
||||
label: List Manufacturers
|
||||
- id: cust_api_v2.vehicle.makes
|
||||
label: List Makes
|
||||
- id: cust_api_v2.vehicle.create
|
||||
label: Add
|
||||
- id: cust_api_v2.vehicle.update
|
||||
label: Update
|
||||
- id: cust_api_v2.vehicle.list
|
||||
label: List
|
||||
- id: cust_api_v2.vehicle.batteries
|
||||
label: Compatible Batteries
|
||||
- id: cust_api_v2.vehicle.delete
|
||||
label: Delete
|
||||
- id: cust_api_v2.warranty
|
||||
label: Warranty
|
||||
acls:
|
||||
- id: cust_api_v2.warranty.activate
|
||||
label: Activate
|
||||
- id: cust_api_v2.warranty.check
|
||||
label: Check Status
|
||||
- id: cust_api_v2.warranty.register
|
||||
label: Register
|
||||
308
config/packages/catalyst_menu.yaml
Normal file
|
|
@ -0,0 +1,308 @@
|
|||
catalyst_menu:
|
||||
main:
|
||||
- id: home
|
||||
acl: dashboard.menu
|
||||
label: '[menu.dashboard]'
|
||||
icon: flaticon-line-graph
|
||||
order: 1
|
||||
|
||||
|
||||
- id: user
|
||||
acl: user.menu
|
||||
label: '[menu.user]'
|
||||
icon: flaticon-users
|
||||
order: 2
|
||||
- id: user_list
|
||||
acl: user.list
|
||||
label: '[menu.user.users]'
|
||||
parent: user
|
||||
- id: role_list
|
||||
acl: role.list
|
||||
label: '[menu.user.roles]'
|
||||
parent: user
|
||||
|
||||
- id: apiuser
|
||||
acl: apiuser.menu
|
||||
label: '[menu.apiuser]'
|
||||
icon: flaticon-users
|
||||
order: 3
|
||||
- id: api_user_list
|
||||
acl: apiuser.list
|
||||
label: '[menu.apiuser.users]'
|
||||
parent: apiuser
|
||||
- id: api_role_list
|
||||
acl: apirole.list
|
||||
label: '[menu.apiuser.roles]'
|
||||
parent: apiuser
|
||||
|
||||
- id: logistics
|
||||
acl: logistics.menu
|
||||
label: '[menu.logistics]'
|
||||
icon: fa fa-truck
|
||||
order: 4
|
||||
- id: rider_list
|
||||
acl: rider.list
|
||||
label: '[menu.logistics.riders]'
|
||||
parent: logistics
|
||||
|
||||
- id: battery
|
||||
acl: battery.menu
|
||||
label: '[menu.battery]'
|
||||
icon: fa fa-battery-3
|
||||
order: 5
|
||||
- id: battery_list
|
||||
acl: battery.list
|
||||
label: '[menu.battery.batteries]'
|
||||
parent: battery
|
||||
- id: bmfg_list
|
||||
acl: bmfg.list
|
||||
label: '[menu.battery.manufacturers]'
|
||||
parent: battery
|
||||
- id: bmodel_list
|
||||
acl: bmodel.list
|
||||
label: '[menu.battery.models]'
|
||||
parent: battery
|
||||
- id: bsize_list
|
||||
acl: bsize.list
|
||||
label: '[menu.battery.sizes]'
|
||||
parent: battery
|
||||
- id: promo_list
|
||||
acl: promo.list
|
||||
label: '[menu.battery.promos]'
|
||||
parent: battery
|
||||
|
||||
- id: sapbattery
|
||||
acl: sap_battery.menu
|
||||
label: '[menu.sapbattery]'
|
||||
icon: fa fa-battery
|
||||
order: 6
|
||||
- id: sapbattery_list
|
||||
acl: sap_battery.list
|
||||
label: '[menu.sapbattery.batteries]'
|
||||
parent: sapbattery
|
||||
- id: sapbrand_list
|
||||
acl: sap_brand.list
|
||||
label: '[menu.sapbattery.brands]'
|
||||
parent: sapbattery
|
||||
- id: sapbsize_list
|
||||
acl: sap_bsize.list
|
||||
label: '[menu.sapbattery.sizes]'
|
||||
parent: sapbattery
|
||||
- id: sapcsize_list
|
||||
acl: sap_csize.list
|
||||
label: '[menu.sapbattery.csizes]'
|
||||
parent: sapbattery
|
||||
|
||||
|
||||
- id: vehicle
|
||||
acl: vehicle.menu
|
||||
label: '[menu.vehicle]'
|
||||
icon: fa fa-car
|
||||
order: 7
|
||||
- id: vehicle_list
|
||||
acl: vehicle.list
|
||||
label: '[menu.vehicle.vehicles]'
|
||||
parent: vehicle
|
||||
- id: vmfg_list
|
||||
acl: vmfg.list
|
||||
label: '[menu.vehicle.manufacturers]'
|
||||
parent: vehicle
|
||||
|
||||
- id: location
|
||||
acl: location.menu
|
||||
label: '[menu.location]'
|
||||
icon: fa fa-home
|
||||
order: 8
|
||||
- id: outlet_list
|
||||
acl: outlet.menu
|
||||
label: '[menu.location.outlets]'
|
||||
parent: location
|
||||
- id: hub_list
|
||||
acl: hub.menu
|
||||
label: '[menu.location.hubs]'
|
||||
parent: location
|
||||
- id: dealer_list
|
||||
acl: dealer.list
|
||||
label: '[menu.location.dealers]'
|
||||
parent: location
|
||||
- id: geofence_list
|
||||
acl: geofence.menu
|
||||
label: '[menu.location.geofence]'
|
||||
parent: location
|
||||
|
||||
|
||||
- id: joborder
|
||||
acl: joborder.menu
|
||||
label: '[menu.joborder]'
|
||||
icon: flaticon-calendar-3
|
||||
order: 9
|
||||
- id: jo_in
|
||||
acl: jo_in.list
|
||||
label: '[menu.joborder.incoming]'
|
||||
parent: joborder
|
||||
- id: jo_proc
|
||||
acl: jo_proc.list
|
||||
label: '[menu.joborder.dispatch]'
|
||||
parent: joborder
|
||||
- id: jo_resq_proc
|
||||
acl: jo_resq_proc.list
|
||||
label: '[menu.joborder.resqdispatch]'
|
||||
parent: joborder
|
||||
- id: jo_assign
|
||||
acl: jo_assign.list
|
||||
label: '[menu.joborder.assignment]'
|
||||
parent: joborder
|
||||
- id: jo_fulfill
|
||||
acl: jo_fulfill.list
|
||||
label: '[menu.joborder.fulfillment]'
|
||||
parent: joborder
|
||||
- id: jo_open
|
||||
acl: jo_open.list
|
||||
label: '[menu.joborder.open]'
|
||||
parent: joborder
|
||||
- id: jo_all
|
||||
acl: jo_all.list
|
||||
label: '[menu.joborder.viewall]'
|
||||
parent: joborder
|
||||
- id: jo_hub_view
|
||||
acl: jo_hub.list
|
||||
label: '[menu.joborder.hubview]'
|
||||
parent: joborder
|
||||
- id: jo_resq_all
|
||||
acl: jo_resq_all.list
|
||||
label: '[menu.joborder.resqall]'
|
||||
parent: joborder
|
||||
|
||||
- id: support
|
||||
acl: support.menu
|
||||
label: '[menu.support]'
|
||||
icon: flaticon-support
|
||||
order: 11
|
||||
- id: customer_list
|
||||
acl: customer.list
|
||||
label: '[menu.support.customers]'
|
||||
parent: support
|
||||
- id: ticket_list
|
||||
acl: ticket.list
|
||||
label: '[menu.support.tickets]'
|
||||
parent: support
|
||||
- id: general_search
|
||||
acl: general.search
|
||||
label: '[menu.support.search]'
|
||||
parent: support
|
||||
- id: warranty_search
|
||||
acl: warranty.search
|
||||
label: '[menu.support.warrantysearch]'
|
||||
parent: support
|
||||
- id: privacy_policy_list
|
||||
acl: privacy_policy.list
|
||||
label: '[menu.support.privacypolicy]'
|
||||
parent: support
|
||||
- id: warranty_list
|
||||
acl: warranty.list
|
||||
label: '[menu.support.warranty]'
|
||||
parent: support
|
||||
- id: warranty_upload
|
||||
acl: warranty.upload
|
||||
label: '[menu.support.warrantyupload]'
|
||||
parent: support
|
||||
- id: static_content_list
|
||||
acl: static_content.list
|
||||
label: '[menu.support.staticcontent]'
|
||||
parent: support
|
||||
- id: customertag_list
|
||||
acl: customer_tag.list
|
||||
label: '[menu.support.customertags]'
|
||||
parent: support
|
||||
- id: reviewtag_list
|
||||
acl: review_tag.list
|
||||
label: '[menu.support.reviewtags]'
|
||||
parent: support
|
||||
|
||||
- id: service
|
||||
acl: service.menu
|
||||
label: '[menu.service]'
|
||||
icon: flaticon-squares
|
||||
order: 12
|
||||
- id: service_list
|
||||
acl: service.list
|
||||
label: '[menu.service.services]'
|
||||
parent: service
|
||||
|
||||
- id: partner
|
||||
acl: partner.menu
|
||||
label: '[menu.partner]'
|
||||
icon: flaticon-network
|
||||
order: 13
|
||||
- id: partner_list
|
||||
acl: partner.list
|
||||
label: '[menu.partner.partners]'
|
||||
parent: partner
|
||||
- id: review_list
|
||||
acl: review.list
|
||||
label: '[menu.partner.reviews]'
|
||||
parent: partner
|
||||
|
||||
- id: motolite_event
|
||||
acl: motolite_event.menu
|
||||
label: '[menu.motolite_event]'
|
||||
icon: flaticon-event-calendar-symbol
|
||||
order: 14
|
||||
- id: motolite_event_list
|
||||
acl: motolite_event.list
|
||||
label: '[menu.motolite_event.events]'
|
||||
parent: motolite_event
|
||||
|
||||
- id: analytics
|
||||
acl: analytics.menu
|
||||
label: '[menu.analytics]'
|
||||
icon: flaticon-graphic
|
||||
order: 15
|
||||
- id: analytics_forecast_form
|
||||
acl: analytics.forecast
|
||||
label: '[menu.analytics.forecasting]'
|
||||
parent: analytics
|
||||
|
||||
- id: database
|
||||
acl: database.menu
|
||||
label: '[menu.database]'
|
||||
icon: fa fa-database
|
||||
order: 16
|
||||
- id: ticket_type_list
|
||||
acl: ticket_type.menu
|
||||
label: '[menu.database.tickettypes]'
|
||||
parent: database
|
||||
- id: subticket_type_list
|
||||
acl: subticket_type.menu
|
||||
label: '[menu.database.subtickettypes]'
|
||||
parent: database
|
||||
- id: emergency_type_list
|
||||
acl: emergency_type.menu
|
||||
label: '[menu.database.emergencytypes]'
|
||||
parent: database
|
||||
- id: ownership_type_list
|
||||
acl: ownership_type.menu
|
||||
label: '[menu.database.ownershiptypes]'
|
||||
parent: database
|
||||
- id: service_offering_list
|
||||
acl: service_offering.menu
|
||||
label: '[menu.database.serviceofferings]'
|
||||
parent: database
|
||||
- id: item_type_list
|
||||
acl: item_type.menu
|
||||
label: '[menu.database.itemtypes]'
|
||||
parent: database
|
||||
|
||||
- id: item
|
||||
acl: item.menu
|
||||
label: Item Management
|
||||
icon: fa fa-boxes
|
||||
order: 10
|
||||
- id: price_tier_list
|
||||
acl: price_tier.list
|
||||
label: Price Tiers
|
||||
parent: item
|
||||
- id: item_pricing
|
||||
acl: item_pricing.update
|
||||
label: Item Pricing
|
||||
parent: item
|
||||
|
|
@ -11,6 +11,8 @@ doctrine:
|
|||
driver: 'pdo_mysql'
|
||||
server_version: '5.7'
|
||||
charset: utf8mb4
|
||||
options:
|
||||
!php/const PDO::MYSQL_ATTR_LOCAL_INFILE: true
|
||||
|
||||
# With Symfony 3.3, remove the `resolve:` prefix
|
||||
url: '%env(resolve:DATABASE_URL)%'
|
||||
|
|
|
|||
|
|
@ -9,8 +9,14 @@ security:
|
|||
entity:
|
||||
class: App\Entity\User
|
||||
property: username
|
||||
api_key_user_provider:
|
||||
id: Catalyst\APIBundle\Security\APIKeyUserProvider
|
||||
api_provider:
|
||||
entity:
|
||||
class: App\Entity\ApiUser
|
||||
property: api_key
|
||||
api_v2_provider:
|
||||
entity:
|
||||
class: App\Entity\CustomerUser
|
||||
property: api_key
|
||||
firewalls:
|
||||
dev:
|
||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||
|
|
@ -43,21 +49,57 @@ security:
|
|||
pattern: ^\/rapi\/
|
||||
security: false
|
||||
|
||||
test_capi:
|
||||
pattern: ^\/test_capi\/
|
||||
security: false
|
||||
|
||||
insurance:
|
||||
pattern: ^\/insurance\/
|
||||
security: false
|
||||
|
||||
paymongo:
|
||||
pattern: ^\/paymongo\/
|
||||
security: false
|
||||
|
||||
cust_api_v2:
|
||||
pattern: ^\/apiv2\/(?!register|register\/|number_confirm|number_confirm\/|code_validate|code_validate\/|resend_code|resend_code\/|version_check|version_check\/|account|account\/|account_code_validate|account_code_validate\/|account_resend_code|account_resend_code\/)
|
||||
provider: api_v2_provider
|
||||
access_denied_handler: Catalyst\ApiBundle\Service\AccessDeniedHandler
|
||||
stateless: true
|
||||
guard:
|
||||
authenticators:
|
||||
- Catalyst\ApiBundle\Security\Authenticator
|
||||
|
||||
cust_api_v2_guest:
|
||||
pattern: ^\/apiv2\/(register|register\/|number_confirm|number_confirm\/|code_validate|code_validate\/|resend_code|resend_code\/|version_check|version_check\/|account|account\/|account_code_validate|account_code_validate\/|account_resend_code|account_resend_code\/)
|
||||
security: false
|
||||
|
||||
warranty_api:
|
||||
pattern: ^\/capi\/
|
||||
provider: api_provider
|
||||
access_denied_handler: Catalyst\ApiBundle\Service\AccessDeniedHandler
|
||||
stateless: true
|
||||
simple_preauth:
|
||||
authenticator: Catalyst\APIBundle\Security\APIKeyAuthenticator
|
||||
provider: api_key_user_provider
|
||||
user_checker: Catalyst\AuthBundle\Service\UserChecker
|
||||
guard:
|
||||
authenticators:
|
||||
- Catalyst\ApiBundle\Security\Authenticator
|
||||
|
||||
new_rider_api:
|
||||
pattern: ^\/rider_api\/
|
||||
provider: api_provider
|
||||
access_denied_handler: Catalyst\ApiBundle\Service\AccessDeniedHandler
|
||||
stateless: true
|
||||
simple_preauth:
|
||||
authenticator: Catalyst\APIBundle\Security\APIKeyAuthenticator
|
||||
provider: api_key_user_provider
|
||||
user_checker: Catalyst\AuthBundle\Service\UserChecker
|
||||
guard:
|
||||
authenticators:
|
||||
- Catalyst\ApiBundle\Security\Authenticator
|
||||
|
||||
third_party_api:
|
||||
pattern: ^\/tapi\/
|
||||
provider: api_provider
|
||||
access_denied_handler: Catalyst\ApiBundle\Service\AccessDeniedHandler
|
||||
stateless: true
|
||||
guard:
|
||||
authenticators:
|
||||
- Catalyst\ApiBundle\Security\Authenticator
|
||||
|
||||
main:
|
||||
provider: user_provider
|
||||
|
|
@ -72,6 +114,7 @@ security:
|
|||
lifetime: 604800
|
||||
path: /
|
||||
user_checker: Catalyst\AuthBundle\Service\UserChecker
|
||||
switch_user: { role: ROLE_SUPER_ADMIN }
|
||||
|
||||
# activate different ways to authenticate
|
||||
|
||||
|
|
|
|||
|
|
@ -43,20 +43,6 @@ services:
|
|||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
|
||||
Catalyst\AuthBundle\Service\ACLGenerator:
|
||||
arguments:
|
||||
$router: "@router.default"
|
||||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
$acl_file: "%app_acl_file%"
|
||||
|
||||
Catalyst\AuthBundle\Service\ACLVoter:
|
||||
arguments:
|
||||
$user_class: "App\\Entity\\User"
|
||||
tags: ['security.voter']
|
||||
|
||||
Catalyst\AuthBundle\Service\UserChecker:
|
||||
|
||||
App\Service\FileUploader:
|
||||
arguments:
|
||||
$target_dir: '%image_upload_directory%'
|
||||
|
|
@ -115,50 +101,6 @@ services:
|
|||
arguments:
|
||||
$redis_client: "@App\\Service\\RedisClientProvider"
|
||||
|
||||
Catalyst\APIBundle\Security\APIKeyUserProvider:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
Catalyst\APIBundle\Security\APIKeyAuthenticator:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
Catalyst\APIBundle\Command\UserCreateCommand:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
tags: ['console.command']
|
||||
|
||||
Catalyst\APIBundle\Command\TestCommand:
|
||||
tags: ['console.command']
|
||||
|
||||
Catalyst\APIBundle\Command\TestAPICommand:
|
||||
tags: ['console.command']
|
||||
|
||||
Catalyst\APIBundle\Access\Voter:
|
||||
arguments:
|
||||
$acl_gen: "@Catalyst\\APIBundle\\Access\\Generator"
|
||||
$user_class: "Catalyst\\APIBundle\\Entity\\User"
|
||||
tags: ['security.voter']
|
||||
|
||||
Catalyst\APIBundle\Access\Generator:
|
||||
arguments:
|
||||
$router: "@router.default"
|
||||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
$acl_file: "%api_acl_file%"
|
||||
|
||||
Catalyst\MenuBundle\Menu\Generator:
|
||||
arguments:
|
||||
$router: "@router.default"
|
||||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
|
||||
Catalyst\MenuBundle\Listener\MenuAnnotationListener:
|
||||
arguments:
|
||||
$menu_name: "main_menu"
|
||||
tags:
|
||||
- { name: kernel.event_listener, event: kernel.controller, method: onKernelController }
|
||||
|
||||
# invoice generator
|
||||
App\Service\InvoiceGenerator\ResqInvoiceGenerator: ~
|
||||
|
||||
|
|
|
|||
|
|
@ -185,3 +185,43 @@ api_jo_info:
|
|||
path: /api/job_order/{id}/info
|
||||
controller: App\Controller\APIController::getJobOrderInfo
|
||||
methods: [GET]
|
||||
|
||||
api_ongoing_job_orders:
|
||||
path: /api/job_orders/ongoing
|
||||
controller: App\Controller\APIController::getAllOngoingJobOrders
|
||||
methods: [GET]
|
||||
|
||||
api_ongoing_jo_count:
|
||||
path: /api/job_orders/ongoing/count
|
||||
controller: App\Controller\APIController::getOngoingJobOrderCount
|
||||
methods: [GET]
|
||||
|
||||
api_new_location:
|
||||
path: /api/new_location
|
||||
controller: App\Controller\APIController::addLocation
|
||||
methods: [POST]
|
||||
|
||||
api_locations:
|
||||
path: /api/locations
|
||||
controller: App\Controller\APIController::getLocations
|
||||
methods: [GET]
|
||||
|
||||
api_cust_vehicle_remove:
|
||||
path: /api/vehicles/{id}/remove
|
||||
controller: App\Controller\APIController::removeVehicle
|
||||
methods: [POST]
|
||||
|
||||
api_latest_job_order:
|
||||
path: /api/job_order/latest
|
||||
controller: App\Controller\APIController::getLatestJobOrder
|
||||
methods: [GET]
|
||||
|
||||
api_customer_hash_get:
|
||||
path: /api/customer_hash
|
||||
controller: App\Controller\APIController::getCustomerHash
|
||||
methods: [GET]
|
||||
|
||||
#api_completed_job_orders:
|
||||
# path: /api/job_orders/completed
|
||||
# controller: App\Controller\APIController::getCompletedJobOrders
|
||||
# methods: [GET]
|
||||
|
|
|
|||
315
config/routes/apiv2.yaml
Normal file
|
|
@ -0,0 +1,315 @@
|
|||
# api
|
||||
|
||||
apiv2_register:
|
||||
path: /apiv2/register
|
||||
controller: App\Controller\CustomerAppAPI\AuthController::register
|
||||
methods: [POST]
|
||||
|
||||
apiv2_confirm:
|
||||
path: /apiv2/number_confirm
|
||||
controller: App\Controller\CustomerAppAPI\AuthController::confirmNumber
|
||||
methods: [POST]
|
||||
|
||||
apiv2_validate:
|
||||
path: /apiv2/code_validate
|
||||
controller: App\Controller\CustomerAppAPI\AuthController::validateCode
|
||||
methods: [POST]
|
||||
|
||||
apiv2_info_get:
|
||||
path: /apiv2/info
|
||||
controller: App\Controller\CustomerAppAPI\CustomerController::getInfo
|
||||
methods: [GET]
|
||||
|
||||
apiv2_info_update:
|
||||
path: /apiv2/info
|
||||
controller: App\Controller\CustomerAppAPI\CustomerController::updateInfo
|
||||
methods: [POST]
|
||||
|
||||
apiv2_status:
|
||||
path: /apiv2/status
|
||||
controller: App\Controller\CustomerAppAPI\CustomerController::getStatus
|
||||
methods: [GET]
|
||||
|
||||
apiv2_vehicle_mfg_list:
|
||||
path: /apiv2/vehicle/mfgs
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::listVehicleManufacturers
|
||||
methods: [GET]
|
||||
|
||||
apiv2_vehicle_make_list:
|
||||
path: /apiv2/vehicle/mfgs/{mfg_id}/makes
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::listVehicleMakes
|
||||
methods: [GET]
|
||||
|
||||
apiv2_cust_vehicle_add:
|
||||
path: /apiv2/vehicles
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::addVehicle
|
||||
methods: [POST]
|
||||
|
||||
apiv2_cust_vehicle_info:
|
||||
path: /apiv2/vehicles/{id}
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::getVehicle
|
||||
methods: [GET]
|
||||
|
||||
apiv2_cust_vehicle_update:
|
||||
path: /apiv2/vehicles/{id}
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::updateVehicle
|
||||
methods: [POST]
|
||||
|
||||
apiv2_cust_vehicle_list:
|
||||
path: /apiv2/vehicles
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::listVehicles
|
||||
methods: [GET]
|
||||
|
||||
apiv2_promo_list:
|
||||
path: /apiv2/promos
|
||||
controller: App\Controller\CustomerAppAPI\PromoController::listPromos
|
||||
methods: [GET]
|
||||
|
||||
apiv2_battery_list:
|
||||
path: /apiv2/vehicles/{vid}/compatible_batteries
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::getCompatibleBatteries
|
||||
methods: [GET]
|
||||
|
||||
apiv2_jo_request:
|
||||
path: /apiv2/job_order
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::requestJobOrder
|
||||
methods: [POST]
|
||||
|
||||
apiv2_estimate:
|
||||
path: /apiv2/estimate
|
||||
controller: App\Controller\CustomerAppAPI\InvoiceController::getEstimate
|
||||
methods: [POST]
|
||||
|
||||
apiv2_ongoing:
|
||||
path: /apiv2/job_order/ongoing
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::getOngoing
|
||||
methods: [GET]
|
||||
|
||||
apiv2_rider_status:
|
||||
path: /apiv2/rider
|
||||
controller: App\Controller\CustomerAppAPI\RiderController::getRiderStatus
|
||||
methods: [GET]
|
||||
|
||||
apiv2_rider_rating_add:
|
||||
path: /apiv2/rider_rating
|
||||
controller: App\Controller\CustomerAppAPI\RiderController::addRiderRating
|
||||
methods: [POST]
|
||||
|
||||
apiv2_jo_cancel:
|
||||
path: /apiv2/job_order/cancel
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController:cancelJobOrder
|
||||
methods: [POST]
|
||||
|
||||
apiv2_jo_history:
|
||||
path: /apiv2/job_order/history
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController:getJOHistory
|
||||
methods: [GET]
|
||||
|
||||
apiv2_jo_invoice:
|
||||
path: /apiv2/job_order/invoice
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController:getJOInvoice
|
||||
methods: [GET]
|
||||
|
||||
apiv2_device_id:
|
||||
path: /apiv2/device_id
|
||||
controller: App\Controller\CustomerAppAPI\DeviceController:updateDeviceID
|
||||
methods: [POST]
|
||||
|
||||
apiv2_privacy:
|
||||
path: /apiv2/privacy
|
||||
controller: App\Controller\CustomerAppAPI\PrivacyController:privacySettings
|
||||
methods: [POST]
|
||||
|
||||
apiv2_resend_code:
|
||||
path: /apiv2/resend_code
|
||||
controller: App\Controller\CustomerAppAPI\AuthController:resendCode
|
||||
methods: [POST]
|
||||
|
||||
apiv2_location_support:
|
||||
path: /apiv2/location_support
|
||||
controller: App\Controller\CustomerAppAPI\LocationController:locationSupport
|
||||
methods: [GET]
|
||||
|
||||
apiv2_activate_warranty:
|
||||
path: /apiv2/activate_warranty
|
||||
controller: App\Controller\CustomerAppAPI\WarrantyController:activateWarranty
|
||||
methods: [POST]
|
||||
|
||||
apiv2_service_list:
|
||||
path: /apiv2/services
|
||||
controller: App\Controller\CustomerAppAPI\ServiceController:listServices
|
||||
methods: [GET]
|
||||
|
||||
apiv2_partner_info:
|
||||
path: /apiv2/partners/{pid}
|
||||
controller: App\Controller\CustomerAppAPI\PartnerController:getPartnerInformation
|
||||
methods: [GET]
|
||||
|
||||
apiv2_partner:
|
||||
path: /apiv2/partners
|
||||
controller: App\Controller\CustomerAppAPI\PartnerController:getClosestPartners
|
||||
methods: [GET]
|
||||
|
||||
apiv2_partner_review:
|
||||
path: /apiv2/partners/{pid}/review
|
||||
controller: App\Controller\CustomerAppAPI\PartnerController:reviewPartner
|
||||
methods: [POST]
|
||||
|
||||
apiv2_nearest_hub_slots:
|
||||
path: /apiv2/hub_slots
|
||||
controller: App\Controller\CustomerAppAPI\LocationController::getNearestHubAndSlots
|
||||
methods: [GET]
|
||||
|
||||
apiv2_new_jo_request:
|
||||
path: /apiv2/new_job_order
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::newRequestJobOrder
|
||||
methods: [POST]
|
||||
|
||||
apiv2_version_check:
|
||||
path: /apiv2/version_check
|
||||
controller: App\Controller\CustomerAppAPI\AppController::versionCheck
|
||||
methods: [GET]
|
||||
|
||||
apiv2_schedule_option_status:
|
||||
path: /apiv2/schedule_option_status
|
||||
controller: App\Controller\CustomerAppAPI\ScheduleController::scheduleOptionStatus
|
||||
methods: [GET]
|
||||
|
||||
# paperless warranty / qr code
|
||||
apiv2_warr_serial_check:
|
||||
path: /apiv2/warranty/{serial}
|
||||
controller: App\Controller\CustomerAppAPI\WarrantyController::warrantyCheck
|
||||
methods: [GET]
|
||||
|
||||
apiv2_warr_serial_register:
|
||||
path: /apiv2/warranty/{serial}
|
||||
controller: App\Controller\CustomerAppAPI\WarrantyController::warrantyRegister
|
||||
methods: [POST]
|
||||
|
||||
apiv2_jo_info:
|
||||
path: /apiv2/job_order/{id}/info
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::getJobOrderInfo
|
||||
methods: [GET]
|
||||
|
||||
apiv2_ongoing_job_orders:
|
||||
path: /apiv2/job_orders/ongoing
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::getAllOngoingJobOrders
|
||||
methods: [GET]
|
||||
|
||||
apiv2_ongoing_jo_count:
|
||||
path: /apiv2/job_orders/ongoing/count
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::getOngoingJobOrderCount
|
||||
methods: [GET]
|
||||
|
||||
apiv2_new_location:
|
||||
path: /apiv2/new_location
|
||||
controller: App\Controller\CustomerAppAPI\LocationController::addLocation
|
||||
methods: [POST]
|
||||
|
||||
apiv2_locations:
|
||||
path: /apiv2/locations
|
||||
controller: App\Controller\CustomerAppAPI\LocationController::getLocations
|
||||
methods: [GET]
|
||||
|
||||
apiv2_location_remove:
|
||||
path: /apiv2/locations/{id}/remove
|
||||
controller: App\Controller\CustomerAppAPI\LocationController::removeLocation
|
||||
methods: [POST]
|
||||
|
||||
apiv2_cust_vehicle_remove:
|
||||
path: /apiv2/vehicles/{id}/remove
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::removeVehicle
|
||||
methods: [POST]
|
||||
|
||||
apiv2_latest_job_order:
|
||||
path: /apiv2/job_order/latest
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::getLatestJobOrder
|
||||
methods: [GET]
|
||||
|
||||
apiv2_customer_hash_get:
|
||||
path: /apiv2/customer_hash
|
||||
controller: App\Controller\CustomerAppAPI\CustomerController::getCustomerHash
|
||||
methods: [GET]
|
||||
|
||||
#apiv2_completed_job_orders:
|
||||
# path: /apiv2/job_orders/completed
|
||||
# controller: App\Controller\CustomerAppAPI\JobOrderController::getCompletedJobOrders
|
||||
# methods: [GET]
|
||||
|
||||
# motolite events
|
||||
apiv2_motolite_events:
|
||||
path: /apiv2/motolite_events
|
||||
controller: App\Controller\CustomerAppAPI\MotoliteEventController::getEvents
|
||||
methods: [GET]
|
||||
|
||||
# review tags
|
||||
apiv2_partner_review_tags:
|
||||
path: /apiv2/review_tags/partner
|
||||
controller: App\Controller\CustomerAppAPI\ReviewTagController::getPartnerReviewTags
|
||||
|
||||
apiv2_rider_review_tags:
|
||||
path: /apiv2/review_tags/rider
|
||||
controller: App\Controller\CustomerAppAPI\ReviewTagController::getRiderReviewTags
|
||||
|
||||
# account deletion
|
||||
apiv2_account_delete:
|
||||
path: /apiv2/account_delete
|
||||
controller: App\Controller\CustomerAppAPI\AccountController::deleteAccount
|
||||
methods: [POST]
|
||||
|
||||
apiv2_account_delete_resend_code:
|
||||
path: /apiv2/account_delete_resend_code
|
||||
controller: App\Controller\CustomerAppAPI\AccountController:resendCode
|
||||
methods: [POST]
|
||||
|
||||
apiv2_account_delete_code_validate:
|
||||
path: /apiv2/account_delete_code_validate
|
||||
controller: App\Controller\CustomerAppAPI\AccountController::validateDeleteCode
|
||||
methods: [POST]
|
||||
|
||||
# trade-in support
|
||||
apiv2_cust_vehicle_trade_in_estimate:
|
||||
path: /apiv2/vehicles/{id}/trade_in_estimate
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::getTradeInEstimate
|
||||
methods: [GET]
|
||||
|
||||
# insurance
|
||||
apiv2_insurance_vehicle_maker_list:
|
||||
path: /apiv2/insurance/vehicles/makers
|
||||
controller: App\Controller\CustomerAppAPI\InsuranceController::getVehicleMakers
|
||||
methods: [GET]
|
||||
|
||||
apiv2_insurance_vehicle_model_list:
|
||||
path: /apiv2/insurance/vehicles/models/{maker_id}
|
||||
controller: App\Controller\CustomerAppAPI\InsuranceController::getVehicleModels
|
||||
methods: [GET]
|
||||
|
||||
apiv2_insurance_vehicle_trim_list:
|
||||
path: /apiv2/insurance/vehicles/trims/{model_id}
|
||||
controller: App\Controller\CustomerAppAPI\InsuranceController::getVehicleTrims
|
||||
methods: [GET]
|
||||
|
||||
apiv2_insurance_vehicle_mv_type_list:
|
||||
path: /apiv2/insurance/mvtypes
|
||||
controller: App\Controller\CustomerAppAPI\InsuranceController::getMVTypes
|
||||
methods: [GET]
|
||||
|
||||
apiv2_insurance_vehicle_client_type_list:
|
||||
path: /apiv2/insurance/clienttypes
|
||||
controller: App\Controller\CustomerAppAPI\InsuranceController::getClientTypes
|
||||
methods: [GET]
|
||||
|
||||
apiv2_insurance_application_create:
|
||||
path: /apiv2/insurance/application
|
||||
controller: App\Controller\CustomerAppAPI\InsuranceController::createApplication
|
||||
methods: [POST]
|
||||
|
||||
apiv2_insurance_premiums_banner:
|
||||
path: /apiv2/insurance/premiums_banner
|
||||
controller: App\Controller\CustomerAppAPI\InsuranceController::getPremiumsBanner
|
||||
methods: [GET]
|
||||
|
||||
apiv2_insurance_body_types:
|
||||
path: /apiv2/insurance/body_types
|
||||
controller: App\Controller\CustomerAppAPI\InsuranceController::getBodyTypes
|
||||
methods: [GET]
|
||||
|
|
@ -3,6 +3,10 @@ capi_test:
|
|||
path: /capi/test
|
||||
controller: App\Controller\CAPI\TestController::test
|
||||
|
||||
capi_test_warranty_serial:
|
||||
path: /test_capi/test/warranty_serial
|
||||
controller: App\Controller\CAPI\TestController::warrantySerial
|
||||
|
||||
|
||||
# battery api
|
||||
|
||||
|
|
@ -155,6 +159,12 @@ capi_customer_register:
|
|||
controller: App\Controller\CAPI\CustomerController::register
|
||||
methods: [POST]
|
||||
|
||||
# verify if resq customer
|
||||
capi_customer_verify:
|
||||
path: /capi/customer/{customer_hash}
|
||||
controller: App\Controller\CAPI\CustomerController::verifyCustomer
|
||||
methods: [GET]
|
||||
|
||||
# customer warranty api
|
||||
capi_cwarr_check:
|
||||
path: /capi/customer_warranty/{serial}
|
||||
|
|
@ -178,3 +188,22 @@ capi_dealer_list:
|
|||
path: /capi/dealers
|
||||
controller: App\Controller\CAPI\DealerController::getAll
|
||||
methods: [GET]
|
||||
|
||||
# warranty serial api
|
||||
capi_warranty_serial_upload:
|
||||
path: /capi/warranty_serial/upload
|
||||
controller: App\Controller\CAPI\WarrantySerialController::uploadWarrantySerialFile
|
||||
methods: [POST]
|
||||
|
||||
# pullout form system
|
||||
# hub
|
||||
capi_hub_list:
|
||||
path: /capi/hubs
|
||||
controller: App\Controller\CAPI\HubController::getAll
|
||||
methods: [GET]
|
||||
|
||||
# job order details
|
||||
capi_job_order:
|
||||
path: /capi/job_order/{id}
|
||||
controller: App\Controller\CAPI\JobOrderController::getJobOrder
|
||||
methods: [GET]
|
||||
|
|
|
|||
|
|
@ -95,3 +95,23 @@ capi_rider_jo_start:
|
|||
controller: App\Controller\CAPI\RiderAppController::startJobOrder
|
||||
methods: [POST]
|
||||
|
||||
# trade-ins
|
||||
capi_rider_battery_sizes:
|
||||
path: /rider_api/battery_sizes
|
||||
controller: App\Controller\CAPI\RiderAppController::getBatterySizes
|
||||
methods: [GET]
|
||||
|
||||
capi_rider_trade_in_types:
|
||||
path: /rider_api/trade_in_types
|
||||
controller: App\Controller\CAPI\RiderAppController::getTradeInTypes
|
||||
methods: [GET]
|
||||
|
||||
capi_rider_battery_info:
|
||||
path: /rider_api/battery/{serial}
|
||||
controller: App\Controller\CAPI\RiderAppController::getBatteryInfo
|
||||
methods: [GET]
|
||||
|
||||
capi_rider_update_jo:
|
||||
path: /rider_api/job_order/update
|
||||
controller: App\Controller\CAPI\RiderAppController::updateJobOrder
|
||||
methods: [POST]
|
||||
|
|
|
|||
227
config/routes/customer_api.yaml
Normal file
|
|
@ -0,0 +1,227 @@
|
|||
# api
|
||||
|
||||
cust_api_register:
|
||||
path: /apiv2/register
|
||||
controller: App\Controller\CustomerAppAPI\AuthController::register
|
||||
methods: [POST]
|
||||
|
||||
cust_api_confirm:
|
||||
path: /apiv2/number_confirm
|
||||
controller: App\Controller\CustomerAppAPI\AuthController::confirmNumber
|
||||
methods: [POST]
|
||||
|
||||
cust_api_validate:
|
||||
path: /apiv2/code_validate
|
||||
controller: App\Controller\CustomerAppAPI\AuthController::validateCode
|
||||
methods: [POST]
|
||||
|
||||
cust_api_info_get:
|
||||
path: /apiv2/info
|
||||
controller: App\Controller\CustomerAppAPI\CustomerController::getInfo
|
||||
methods: [GET]
|
||||
|
||||
cust_api_info_update:
|
||||
path: /apiv2/info
|
||||
controller: App\Controller\CustomerAppAPI\CustomerController::updateInfo
|
||||
methods: [POST]
|
||||
|
||||
cust_api_status:
|
||||
path: /apiv2/status
|
||||
controller: App\Controller\CustomerAppAPI\CustomerController::getStatus
|
||||
methods: [GET]
|
||||
|
||||
cust_api_vehicle_mfg_list:
|
||||
path: /apiv2/vehicle/mfgs
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::listVehicleManufacturers
|
||||
methods: [GET]
|
||||
|
||||
cust_api_vehicle_make_list:
|
||||
path: /apiv2/vehicle/mfgs/{mfg_id}/makes
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::listVehicleMakes
|
||||
methods: [GET]
|
||||
|
||||
cust_api_cust_vehicle_add:
|
||||
path: /apiv2/vehicles
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::addVehicle
|
||||
methods: [POST]
|
||||
|
||||
cust_api_cust_vehicle_update:
|
||||
path: /apiv2/vehicles/{id}
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::updateVehicle
|
||||
methods: [POST]
|
||||
|
||||
cust_api_cust_vehicle_list:
|
||||
path: /apiv2/vehicles
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::listVehicles
|
||||
methods: [GET]
|
||||
|
||||
cust_api_promo_list:
|
||||
path: /apiv2/promos
|
||||
controller: App\Controller\CustomerAppAPI\PromoController::listPromos
|
||||
methods: [GET]
|
||||
|
||||
cust_api_battery_list:
|
||||
path: /apiv2/vehicles/{vid}/compatible_batteries
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::getCompatibleBatteries
|
||||
methods: [GET]
|
||||
|
||||
cust_api_jo_request:
|
||||
path: /apiv2/job_order
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::requestJobOrder
|
||||
methods: [POST]
|
||||
|
||||
cust_api_estimate:
|
||||
path: /apiv2/estimate
|
||||
controller: App\Controller\CustomerAppAPI\EstimateController::getEstimate
|
||||
methods: [POST]
|
||||
|
||||
cust_api_ongoing:
|
||||
path: /apiv2/job_order/ongoing
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::getOngoing
|
||||
methods: [GET]
|
||||
|
||||
cust_api_rider_status:
|
||||
path: /apiv2/rider
|
||||
controller: App\Controller\CustomerAppAPI\RiderController::getRiderStatus
|
||||
methods: [GET]
|
||||
|
||||
cust_api_rider_rating_add:
|
||||
path: /apiv2/rider_rating
|
||||
controller: App\Controller\CustomerAppAPI\RiderController::addRiderRating
|
||||
methods: [POST]
|
||||
|
||||
cust_api_jo_cancel:
|
||||
path: /apiv2/job_order/cancel
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController:cancelJobOrder
|
||||
methods: [POST]
|
||||
|
||||
cust_api_jo_history:
|
||||
path: /apiv2/job_order/history
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController:getJOHistory
|
||||
methods: [GET]
|
||||
|
||||
cust_api_jo_invoice:
|
||||
path: /apiv2/job_order/invoice
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController:getJOInvoice
|
||||
methods: [GET]
|
||||
|
||||
cust_api_device_id:
|
||||
path: /apiv2/device_id
|
||||
controller: App\Controller\CustomerAppAPI\DeviceController:updateDeviceID
|
||||
methods: [POST]
|
||||
|
||||
cust_api_privacy:
|
||||
path: /apiv2/privacy
|
||||
controller: App\Controller\CustomerAppAPI\PrivacyController:privacySettings
|
||||
methods: [POST]
|
||||
|
||||
cust_api_resend_code:
|
||||
path: /apiv2/resend_code
|
||||
controller: App\Controller\CustomerAppAPI\AuthController:resendCode
|
||||
methods: [POST]
|
||||
|
||||
cust_api_location_support:
|
||||
path: /apiv2/location_support
|
||||
controller: App\Controller\CustomerAppAPI\LocationController:locationSupport
|
||||
methods: [GET]
|
||||
|
||||
cust_api_activate_warranty:
|
||||
path: /apiv2/activate_warranty
|
||||
controller: App\Controller\CustomerAppAPI\WarrantyController:activateWarranty
|
||||
methods: [POST]
|
||||
|
||||
cust_api_service_list:
|
||||
path: /apiv2/services
|
||||
controller: App\Controller\CustomerAppAPI\ServiceController:listServices
|
||||
methods: [GET]
|
||||
|
||||
cust_api_partner_info:
|
||||
path: /apiv2/partners/{pid}
|
||||
controller: App\Controller\CustomerAppAPI\PartnerController:getPartnerInformation
|
||||
methods: [GET]
|
||||
|
||||
cust_api_partner:
|
||||
path: /apiv2/partners
|
||||
controller: App\Controller\CustomerAppAPI\PartnerController:getClosestPartners
|
||||
methods: [GET]
|
||||
|
||||
cust_api_partner_review:
|
||||
path: /apiv2/partners/{pid}/review
|
||||
controller: App\Controller\CustomerAppAPI\PartnerController:reviewPartner
|
||||
methods: [POST]
|
||||
|
||||
cust_api_nearest_hub_slots:
|
||||
path: /apiv2/hub_slots
|
||||
controller: App\Controller\CustomerAppAPI\LocationController::getNearestHubAndSlots
|
||||
methods: [GET]
|
||||
|
||||
cust_api_new_jo_request:
|
||||
path: /apiv2/new_job_order
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::newRequestJobOrder
|
||||
methods: [POST]
|
||||
|
||||
cust_api_version_check:
|
||||
path: /apiv2/version_check
|
||||
controller: App\Controller\CustomerAppAPI\AppController::versionCheck
|
||||
methods: [GET]
|
||||
|
||||
cust_api_schedule_option_status:
|
||||
path: /apiv2/schedule_option_status
|
||||
controller: App\Controller\CustomerAppAPI\ScheduleController::scheduleOptionStatus
|
||||
methods: [GET]
|
||||
|
||||
# paperless warranty / qr code
|
||||
cust_api_warr_serial_check:
|
||||
path: /apiv2/warranty/{serial}
|
||||
controller: App\Controller\CustomerAppAPI\WarrantyController::warrantyCheck
|
||||
methods: [GET]
|
||||
|
||||
cust_api_warr_serial_register:
|
||||
path: /apiv2/warranty/{serial}
|
||||
controller: App\Controller\CustomerAppAPI\WarrantyController::warrantyRegister
|
||||
methods: [POST]
|
||||
|
||||
cust_api_jo_info:
|
||||
path: /apiv2/job_order/{id}/info
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::getJobOrderInfo
|
||||
methods: [GET]
|
||||
|
||||
cust_api_ongoing_job_orders:
|
||||
path: /apiv2/job_orders/ongoing
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::getAllOngoingJobOrders
|
||||
methods: [GET]
|
||||
|
||||
cust_api_ongoing_jo_count:
|
||||
path: /apiv2/job_orders/ongoing/count
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::getOngoingJobOrderCount
|
||||
methods: [GET]
|
||||
|
||||
cust_api_new_location:
|
||||
path: /apiv2/new_location
|
||||
controller: App\Controller\CustomerAppAPI\LocationController::addLocation
|
||||
methods: [POST]
|
||||
|
||||
cust_api_locations:
|
||||
path: /apiv2/locations
|
||||
controller: App\Controller\CustomerAppAPI\LocationController::getLocations
|
||||
methods: [GET]
|
||||
|
||||
cust_api_cust_vehicle_remove:
|
||||
path: /apiv2/vehicles/{id}/remove
|
||||
controller: App\Controller\CustomerAppAPI\VehicleController::removeVehicle
|
||||
methods: [POST]
|
||||
|
||||
cust_api_latest_job_order:
|
||||
path: /apiv2/job_order/latest
|
||||
controller: App\Controller\CustomerAppAPI\JobOrderController::getLatestJobOrder
|
||||
methods: [GET]
|
||||
|
||||
cust_api_customer_hash_get:
|
||||
path: /apiv2/customer_hash
|
||||
controller: App\Controller\CustomerAppAPI\CustomerController::getCustomerHash
|
||||
methods: [GET]
|
||||
|
||||
#cust_api_completed_job_orders:
|
||||
# path: /apiv2/job_orders/completed
|
||||
# controller: App\Controller\CustomerAppAPI\JobOrderController::getCompletedJobOrders
|
||||
# methods: [GET]
|
||||
35
config/routes/customer_location.yaml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
customer_location_list:
|
||||
path: /customer-locations
|
||||
controller: App\Controller\CustomerLocationController::index
|
||||
methods: [GET]
|
||||
|
||||
customer_location_rows:
|
||||
path: /customer-locations/rowdata
|
||||
controller: App\Controller\CustomerLocationController::datatableRows
|
||||
methods: [POST]
|
||||
|
||||
customer_location_add_form:
|
||||
path: /customer-locations/newform
|
||||
controller: App\Controller\CustomerLocationController::addForm
|
||||
methods: [GET]
|
||||
|
||||
customer_location_add_submit:
|
||||
path: /customer-locations
|
||||
controller: App\Controller\CustomerLocationController::addSubmit
|
||||
methods: [POST]
|
||||
|
||||
customer_location_update_form:
|
||||
path: /customer-locations/{id}
|
||||
controller: App\Controller\CustomerLocationController::updateForm
|
||||
methods: [GET]
|
||||
|
||||
customer_location_update_submit:
|
||||
path: /customer-locations/{id}
|
||||
controller: App\Controller\CustomerLocationController::updateSubmit
|
||||
methods: [POST]
|
||||
|
||||
customer_location_delete:
|
||||
path: /customer-locations/{id}
|
||||
controller: App\Controller\CustomerLocationController::deleteSubmit
|
||||
methods: [DELETE]
|
||||
|
||||
34
config/routes/emergency_type.yaml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
emergency_type_list:
|
||||
path: /emergency-types
|
||||
controller: App\Controller\EmergencyTypeController::index
|
||||
methods: [GET]
|
||||
|
||||
emergency_type_rows:
|
||||
path: /emergency-types/rowdata
|
||||
controller: App\Controller\EmergencyTypeController::datatableRows
|
||||
methods: [POST]
|
||||
|
||||
emergency_type_add_form:
|
||||
path: /emergency-types/newform
|
||||
controller: App\Controller\EmergencyTypeController::addForm
|
||||
methods: [GET]
|
||||
|
||||
emergency_type_add_submit:
|
||||
path: /emergency-types
|
||||
controller: App\Controller\EmergencyTypeController::addSubmit
|
||||
methods: [POST]
|
||||
|
||||
emergency_type_update_form:
|
||||
path: /emergency-types/{id}
|
||||
controller: App\Controller\EmergencyTypeController::updateForm
|
||||
methods: [GET]
|
||||
|
||||
emergency_type_update_submit:
|
||||
path: /emergency-types/{id}
|
||||
controller: App\Controller\EmergencyTypeController::updateSubmit
|
||||
methods: [POST]
|
||||
|
||||
emergency_type_delete:
|
||||
path: /emergency-types/{id}
|
||||
controller: App\Controller\EmergencyTypeController::deleteSubmit
|
||||
methods: [DELETE]
|
||||
6
config/routes/insurance.yaml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# insurance
|
||||
|
||||
insurance_listener:
|
||||
path: /insurance/listen
|
||||
controller: App\Controller\InsuranceController::listen
|
||||
methods: [POST]
|
||||
14
config/routes/item_pricing.yaml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
item_pricing:
|
||||
path: /item-pricing
|
||||
controller: App\Controller\ItemPricingController::index
|
||||
methods: [GET]
|
||||
|
||||
item_pricing_update:
|
||||
path: /item-pricing
|
||||
controller: App\Controller\ItemPricingController::formSubmit
|
||||
methods: [POST]
|
||||
|
||||
item_pricing_prices:
|
||||
path: /item-pricing/{pt_id}/{it_id}/prices
|
||||
controller: App\Controller\ItemPricingController::itemPrices
|
||||
methods: [GET]
|
||||
34
config/routes/item_type.yaml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
item_type_list:
|
||||
path: /item-types
|
||||
controller: App\Controller\ItemTypeController::index
|
||||
methods: [GET]
|
||||
|
||||
item_type_rows:
|
||||
path: /item-types/rowdata
|
||||
controller: App\Controller\ItemTypeController::datatableRows
|
||||
methods: [POST]
|
||||
|
||||
item_type_add_form:
|
||||
path: /item-types/newform
|
||||
controller: App\Controller\ItemTypeController::addForm
|
||||
methods: [GET]
|
||||
|
||||
item_type_add_submit:
|
||||
path: /item-types
|
||||
controller: App\Controller\ItemTypeController::addSubmit
|
||||
methods: [POST]
|
||||
|
||||
item_type_update_form:
|
||||
path: /item-types/{id}
|
||||
controller: App\Controller\ItemTypeController::updateForm
|
||||
methods: [GET]
|
||||
|
||||
item_type_update_submit:
|
||||
path: /item-types/{id}
|
||||
controller: App\Controller\ItemTypeController::updateSubmit
|
||||
methods: [POST]
|
||||
|
||||
item_type_delete:
|
||||
path: /item-types/{id}
|
||||
controller: App\Controller\ItemTypeController::deleteSubmit
|
||||
methods: [DELETE]
|
||||
|
|
@ -267,3 +267,8 @@ jo_geofence:
|
|||
path: /ajax/job-order/geofence
|
||||
controller: App\Controller\JobOrderController::checkGeofence
|
||||
methods: [GET]
|
||||
|
||||
jo_all_view_form:
|
||||
path: /job-order/all/view/{id}
|
||||
controller: App\Controller\JobOrderController::allViewForm
|
||||
methods: [GET]
|
||||
|
|
|
|||
38
config/routes/motolite_event.yaml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
motolite_event_list:
|
||||
path: /motolite_events
|
||||
controller: App\Controller\MotoliteEventController::index
|
||||
|
||||
motolite_event_rows:
|
||||
path: /motolite_events/rows
|
||||
controller: App\Controller\MotoliteEventController::rows
|
||||
methods: [POST]
|
||||
|
||||
motolite_event_create:
|
||||
path: /motolite_events/create
|
||||
controller: App\Controller\MotoliteEventController::addForm
|
||||
methods: [GET]
|
||||
|
||||
motolite_event_create_submit:
|
||||
path: /motolite_events/create
|
||||
controller: App\Controller\MotoliteEventController::addSubmit
|
||||
methods: [POST]
|
||||
|
||||
motolite_event_upload_image:
|
||||
path: /motolite_events/upload
|
||||
controller: App\Controller\MotoliteEventController::uploadImage
|
||||
methods: [POST]
|
||||
|
||||
motolite_event_update:
|
||||
path: /motolite_events/{id}
|
||||
controller: App\Controller\MotoliteEventController::updateForm
|
||||
methods: [GET]
|
||||
|
||||
motolite_event_update_submit:
|
||||
path: /motolite_events/{id}
|
||||
controller: App\Controller\MotoliteEventController::updateSubmit
|
||||
methods: [POST]
|
||||
|
||||
motolite_event_delete:
|
||||
path: /motolite_events/{id}
|
||||
controller: App\Controller\MotoliteEventController::destroy
|
||||
methods: [DELETE]
|
||||
35
config/routes/ownership_type.yaml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
ownership_type_list:
|
||||
path: /ownership-types
|
||||
controller: App\Controller\OwnershipTypeController::index
|
||||
methods: [GET]
|
||||
|
||||
ownership_type_rows:
|
||||
path: /ownership-types/rowdata
|
||||
controller: App\Controller\OwnershipTypeController::datatableRows
|
||||
methods: [POST]
|
||||
|
||||
ownership_type_add_form:
|
||||
path: /ownership-types/newform
|
||||
controller: App\Controller\OwnershipTypeController::addForm
|
||||
methods: [GET]
|
||||
|
||||
ownership_type_add_submit:
|
||||
path: /ownership-types
|
||||
controller: App\Controller\OwnershipTypeController::addSubmit
|
||||
methods: [POST]
|
||||
|
||||
ownership_type_update_form:
|
||||
path: /ownership-types/{id}
|
||||
controller: App\Controller\OwnershipTypeController::updateForm
|
||||
methods: [GET]
|
||||
|
||||
ownership_type_update_submit:
|
||||
path: /ownership-types/{id}
|
||||
controller: App\Controller\OwnershipTypeController::updateSubmit
|
||||
methods: [POST]
|
||||
|
||||
ownership_type_delete:
|
||||
path: /ownership-types/{id}
|
||||
controller: App\Controller\OwnershipTypeController::deleteSubmit
|
||||
methods: [DELETE]
|
||||
|
||||
16
config/routes/paymongo.yaml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# paymongo
|
||||
|
||||
paymongo_listener:
|
||||
path: /paymongo/listen
|
||||
controller: App\Controller\PayMongoController::listen
|
||||
methods: [POST]
|
||||
|
||||
paymongo_payment_success:
|
||||
path: /paymongo/success
|
||||
controller: App\Controller\PayMongoController::paymentSuccess
|
||||
methods: [GET]
|
||||
|
||||
paymongo_payment_cancelled:
|
||||
path: /paymongo/cancelled
|
||||
controller: App\Controller\PayMongoController::paymentCancelled
|
||||
methods: [GET]
|
||||
34
config/routes/price_tier.yaml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
price_tier_list:
|
||||
path: /price-tiers
|
||||
controller: App\Controller\PriceTierController::index
|
||||
methods: [GET]
|
||||
|
||||
price_tier_rows:
|
||||
path: /price-tiers/rows
|
||||
controller: App\Controller\PriceTierController::datatableRows
|
||||
methods: [POST]
|
||||
|
||||
price_tier_add_form:
|
||||
path: /price-tiers/newform
|
||||
controller: App\Controller\PriceTierController::addForm
|
||||
methods: [GET]
|
||||
|
||||
price_tier_add_submit:
|
||||
path: /price-tiers
|
||||
controller: App\Controller\PriceTierController::addSubmit
|
||||
methods: [POST]
|
||||
|
||||
price_tier_update_form:
|
||||
path: /price-tiers/{id}
|
||||
controller: App\Controller\PriceTierController::updateForm
|
||||
methods: [GET]
|
||||
|
||||
price_tier_update_submit:
|
||||
path: /price-tiers/{id}
|
||||
controller: App\Controller\PriceTierController::updateSubmit
|
||||
methods: [POST]
|
||||
|
||||
price_tier_delete:
|
||||
path: /price-tiers/{id}
|
||||
controller: App\Controller\PriceTierController::deleteSubmit
|
||||
methods: [DELETE]
|
||||
|
|
@ -147,3 +147,23 @@ rep_hub_filter_submit:
|
|||
path: /report/hub_filter_report
|
||||
controller: App\Controller\ReportController::hubFilterSubmit
|
||||
methods: [POST]
|
||||
|
||||
rep_warranty_raffle_form:
|
||||
path: /report/warranty_raffle_report
|
||||
controller: App\Controller\ReportController::warrantyRaffleForm
|
||||
methods: [GET]
|
||||
|
||||
rep_warranty_raffle_submit:
|
||||
path: /report/warranty_raffle_report
|
||||
controller: App\Controller\ReportController::warrantyRaffleSubmit
|
||||
methods: [POST]
|
||||
|
||||
rep_jo_raffle_form:
|
||||
path: /report/jo_raffle_report
|
||||
controller: App\Controller\ReportController::joRaffleForm
|
||||
methods: [GET]
|
||||
|
||||
rep_jo_raffle_submit:
|
||||
path: /report/jo_raffle_report
|
||||
controller: App\Controller\ReportController::joRaffleSubmit
|
||||
methods: [POST]
|
||||
|
|
|
|||
23
config/routes/resq_job_order.yaml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
jo_resq_proc:
|
||||
path: /resq-job-order/processing
|
||||
controller: App\Controller\ResqJobOrderController::listProcessing
|
||||
methods: [GET]
|
||||
|
||||
jo_resq_proc_rows:
|
||||
path: /resq-job-order/processing-rows
|
||||
controller: App\Controller\ResqJobOrderController::datatableRows
|
||||
methods: [POST]
|
||||
defaults:
|
||||
tier: "proc"
|
||||
|
||||
jo_resq_all:
|
||||
path: /resq-job-order/all
|
||||
controller: App\Controller\ResqJobOrderController::listAll
|
||||
methods: [GET]
|
||||
|
||||
jo_resq_all_rows:
|
||||
path: /resq-job-orer/all
|
||||
controller: App\Controller\ResqJobOrderController::datatableRows
|
||||
methods: [POST]
|
||||
defaults:
|
||||
tier: "all"
|
||||
33
config/routes/review_tag.yaml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
reviewtag_list:
|
||||
path: /review_tags
|
||||
controller: App\Controller\ReviewTagController::index
|
||||
|
||||
reviewtag_rows:
|
||||
path: /review_tags/rows
|
||||
controller: App\Controller\ReviewTagController::rows
|
||||
methods: [POST]
|
||||
|
||||
reviewtag_create:
|
||||
path: /review_tags/create
|
||||
controller: App\Controller\ReviewTagController::addForm
|
||||
methods: [GET]
|
||||
|
||||
reviewtag_create_submit:
|
||||
path: /review_tags/create
|
||||
controller: App\Controller\ReviewTagController::addSubmit
|
||||
methods: [POST]
|
||||
|
||||
reviewtag_update:
|
||||
path: /review_tags/{id}
|
||||
controller: App\Controller\ReviewTagController::updateForm
|
||||
methods: [GET]
|
||||
|
||||
reviewtag_update_submit:
|
||||
path: /review_tags/{id}
|
||||
controller: App\Controller\ReviewTagController::updateSubmit
|
||||
methods: [POST]
|
||||
|
||||
reviewtag_delete:
|
||||
path: /review_tags/{id}
|
||||
controller: App\Controller\ReviewTagController::destroy
|
||||
methods: [DELETE]
|
||||
34
config/routes/service_offering.yaml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
service_offering_list:
|
||||
path: /service-offerings
|
||||
controller: App\Controller\ServiceOfferingController::index
|
||||
methods: [GET]
|
||||
|
||||
service_offering_rows:
|
||||
path: /service-offerings/rowdata
|
||||
controller: App\Controller\ServiceOfferingController::datatableRows
|
||||
methods: [POST]
|
||||
|
||||
service_offering_add_form:
|
||||
path: /service-offerings/newform
|
||||
controller: App\Controller\ServiceOfferingController::addForm
|
||||
methods: [GET]
|
||||
|
||||
service_offering_add_submit:
|
||||
path: /service-offerings
|
||||
controller: App\Controller\ServiceOfferingController::addSubmit
|
||||
methods: [POST]
|
||||
|
||||
service_offering_update_form:
|
||||
path: /service-offerings/{id}
|
||||
controller: App\Controller\ServiceOfferingController::updateForm
|
||||
methods: [GET]
|
||||
|
||||
service_offering_update_submit:
|
||||
path: /service-offerings/{id}
|
||||
controller: App\Controller\ServiceOfferingController::updateSubmit
|
||||
methods: [POST]
|
||||
|
||||
service_offering_delete:
|
||||
path: /service-offerings/{id}
|
||||
controller: App\Controller\ServiceOfferingController::deleteSubmit
|
||||
methods: [DELETE]
|
||||
35
config/routes/subticket_type.yaml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
subticket_type_list:
|
||||
path: /subticket-types
|
||||
controller: App\Controller\SubTicketTypeController::index
|
||||
methods: [GET]
|
||||
|
||||
subticket_type_rows:
|
||||
path: /subticket-types/rowdata
|
||||
controller: App\Controller\SubTicketTypeController::datatableRows
|
||||
methods: [POST]
|
||||
|
||||
subticket_type_add_form:
|
||||
path: /subticket-types/newform
|
||||
controller: App\Controller\SubTicketTypeController::addForm
|
||||
methods: [GET]
|
||||
|
||||
subticket_type_add_submit:
|
||||
path: /subticket-types
|
||||
controller: App\Controller\SubTicketTypeController::addSubmit
|
||||
methods: [POST]
|
||||
|
||||
subticket_type_update_form:
|
||||
path: /subticket-types/{id}
|
||||
controller: App\Controller\SubTicketTypeController::updateForm
|
||||
methods: [GET]
|
||||
|
||||
subticket_type_update_submit:
|
||||
path: /subticket-types/{id}
|
||||
controller: App\Controller\SubTicketTypeController::updateSubmit
|
||||
methods: [POST]
|
||||
|
||||
subticket_type_delete:
|
||||
path: /subticket-types/{id}
|
||||
controller: App\Controller\SubTicketTypeController::deleteSubmit
|
||||
methods: [DELETE]
|
||||
|
||||
60
config/routes/tapi.yaml
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# third party api
|
||||
|
||||
# job order
|
||||
tapi_jo_request:
|
||||
path: /tapi/job_order
|
||||
controller: App\Controller\TAPI\JobOrderController::requestJobOrder
|
||||
methods: [POST]
|
||||
|
||||
tapi_estimate:
|
||||
path: /tapi/estimate
|
||||
controller: App\Controller\TAPI\JobOrderController::getEstimate
|
||||
methods: [POST]
|
||||
|
||||
tapi_jo_invoice:
|
||||
path: /tapi/job_order/invoice/{jo_id}
|
||||
controller: App\Controller\TAPI\JobOrderController:getJOInvoice
|
||||
methods: [GET]
|
||||
|
||||
tapi_jo_cancel:
|
||||
path: /tapi/job_order/cancel
|
||||
controller: App\Controller\TAPI\JobOrderController:cancelJobOrder
|
||||
methods: [POST]
|
||||
|
||||
tapi_jo_info:
|
||||
path: /tapi/job_order/{jo_id}/info
|
||||
controller: App\Controller\TAPI\JobOrderController::getJobOrderInfo
|
||||
methods: [GET]
|
||||
|
||||
tapi_location_support:
|
||||
path: /tapi/location_support
|
||||
controller: App\Controller\TAPI\JobOrderController:locationSupport
|
||||
methods: [POST]
|
||||
|
||||
tapi_nearest_hub_slots:
|
||||
path: /tapi/hub_slots
|
||||
controller: App\Controller\TAPI\JobOrderController::getNearestHubAndSlots
|
||||
methods: [POST]
|
||||
|
||||
# vehicle manufacturer and vehicle
|
||||
tapi_vehicle_mfg_list:
|
||||
path: /tapi/vehicle/mfgs
|
||||
controller: App\Controller\TAPI\VehicleController::listVehicleManufacturers
|
||||
methods: [GET]
|
||||
|
||||
tapi_vehicle_make_list:
|
||||
path: /tapi/vehicle/mfgs/{mfg_id}/makes
|
||||
controller: App\Controller\TAPI\VehicleController::listVehicleMakes
|
||||
methods: [GET]
|
||||
|
||||
# battery
|
||||
tapi_battery_list:
|
||||
path: /tapi/vehicles/{vid}/compatible_batteries
|
||||
controller: App\Controller\TAPI\BatteryController::getCompatibleBatteries
|
||||
methods: [POST]
|
||||
|
||||
# promos
|
||||
tapi_promo_list:
|
||||
path: /tapi/promos
|
||||
controller: App\Controller\TAPI\PromoController::listPromos
|
||||
methods: [GET]
|
||||
35
config/routes/ticket_type.yaml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
ticket_type_list:
|
||||
path: /ticket-types
|
||||
controller: App\Controller\TicketTypeController::index
|
||||
methods: [GET]
|
||||
|
||||
ticket_type_rows:
|
||||
path: /ticket-types/rowdata
|
||||
controller: App\Controller\TicketTypeController::datatableRows
|
||||
methods: [POST]
|
||||
|
||||
ticket_type_add_form:
|
||||
path: /ticket-types/newform
|
||||
controller: App\Controller\TicketTypeController::addForm
|
||||
methods: [GET]
|
||||
|
||||
ticket_type_add_submit:
|
||||
path: /ticket-types
|
||||
controller: App\Controller\TicketTypeController::addSubmit
|
||||
methods: [POST]
|
||||
|
||||
ticket_type_update_form:
|
||||
path: /ticket-types/{id}
|
||||
controller: App\Controller\TicketTypeController::updateForm
|
||||
methods: [GET]
|
||||
|
||||
ticket_type_update_submit:
|
||||
path: /ticket-types/{id}
|
||||
controller: App\Controller\TicketTypeController::updateSubmit
|
||||
methods: [POST]
|
||||
|
||||
ticket_type_delete:
|
||||
path: /ticket-types/{id}
|
||||
controller: App\Controller\TicketTypeController::deleteSubmit
|
||||
methods: [DELETE]
|
||||
|
||||
|
|
@ -13,6 +13,10 @@ parameters:
|
|||
cvu_brand_id: "%env(CVU_BRAND_ID)%"
|
||||
country_code: "%env(COUNTRY_CODE)%"
|
||||
api_version: "%env(API_VERSION)%"
|
||||
android_app_version: "%env(ANDROID_APP_VERSION)%"
|
||||
ios_app_version: "%env(IOS_APP_VERSION)%"
|
||||
insurance_premiums_banner_url: "%env(INSURANCE_PREMIUMS_BANNER_URL)%"
|
||||
enabled_hub_filters: "%env(ENABLED_HUB_FILTERS)%"
|
||||
|
||||
services:
|
||||
# default configuration for services in *this* file
|
||||
|
|
@ -43,20 +47,6 @@ services:
|
|||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
|
||||
Catalyst\AuthBundle\Service\ACLGenerator:
|
||||
arguments:
|
||||
$router: "@router.default"
|
||||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
$acl_file: "%app_acl_file%"
|
||||
|
||||
Catalyst\AuthBundle\Service\ACLVoter:
|
||||
arguments:
|
||||
$user_class: "App\\Entity\\User"
|
||||
tags: ['security.voter']
|
||||
|
||||
Catalyst\AuthBundle\Service\UserChecker:
|
||||
|
||||
App\Service\FileUploader:
|
||||
arguments:
|
||||
$target_dir: '%image_upload_directory%'
|
||||
|
|
@ -81,6 +71,11 @@ services:
|
|||
$redis_client: "@App\\Service\\RedisClientProvider"
|
||||
$key: "mqtt_events"
|
||||
|
||||
App\Service\MQTTClientApiv2:
|
||||
arguments:
|
||||
$redis_client: "@App\\Service\\RedisClientProvider"
|
||||
$key: "mqtt_events"
|
||||
|
||||
App\Service\APNSClient:
|
||||
arguments:
|
||||
$redis_client: "@App\\Service\\RedisClientProvider"
|
||||
|
|
@ -111,60 +106,29 @@ services:
|
|||
$cvu_mfg_id: "%env(CVU_MFG_ID)%"
|
||||
$cvu_brand_id: "%env(CVU_BRAND_ID)%"
|
||||
|
||||
App\Command\LoadWarrantySerialCommand:
|
||||
arguments:
|
||||
$callback_url: "%env(WARRANTY_SERIAL_CALLBACK_URL)%"
|
||||
|
||||
App\Command\ProcessLatePaymongoTransactionsCommand:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
$paymongo: "@App\\Service\\PayMongoConnector"
|
||||
$webhook_id: "%env(PAYMONGO_WEBHOOK_ID)%"
|
||||
|
||||
# rider tracker service
|
||||
App\Service\RiderTracker:
|
||||
arguments:
|
||||
$redis_client: "@App\\Service\\RedisClientProvider"
|
||||
|
||||
Catalyst\APIBundle\Security\APIKeyUserProvider:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
Catalyst\APIBundle\Security\APIKeyAuthenticator:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
Catalyst\APIBundle\Command\UserCreateCommand:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
tags: ['console.command']
|
||||
|
||||
Catalyst\APIBundle\Command\TestCommand:
|
||||
tags: ['console.command']
|
||||
|
||||
Catalyst\APIBundle\Command\TestAPICommand:
|
||||
tags: ['console.command']
|
||||
|
||||
Catalyst\APIBundle\Access\Voter:
|
||||
arguments:
|
||||
$acl_gen: "@Catalyst\\APIBundle\\Access\\Generator"
|
||||
$user_class: "Catalyst\\APIBundle\\Entity\\User"
|
||||
tags: ['security.voter']
|
||||
|
||||
Catalyst\APIBundle\Access\Generator:
|
||||
arguments:
|
||||
$router: "@router.default"
|
||||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
$acl_file: "%api_acl_file%"
|
||||
|
||||
Catalyst\MenuBundle\Menu\Generator:
|
||||
arguments:
|
||||
$router: "@router.default"
|
||||
$cache_dir: "%kernel.cache_dir%"
|
||||
$config_dir: "%kernel.root_dir%/../config"
|
||||
|
||||
Catalyst\MenuBundle\Listener\MenuAnnotationListener:
|
||||
arguments:
|
||||
$menu_name: "main_menu"
|
||||
tags:
|
||||
- { name: kernel.event_listener, event: kernel.controller, method: onKernelController }
|
||||
|
||||
# invoice generator
|
||||
App\Service\InvoiceGenerator\ResqInvoiceGenerator: ~
|
||||
|
||||
# invoice generator interface
|
||||
App\Service\InvoiceGeneratorInterface: "@App\\Service\\InvoiceGenerator\\ResqInvoiceGenerator"
|
||||
App\Service\InvoiceGeneratorInterface: "@App\\Service\\InvoiceManager"
|
||||
|
||||
# invoice manager
|
||||
App\Service\InvoiceManager: ~
|
||||
|
||||
# job order generator
|
||||
App\Service\JobOrderHandler\ResqJobOrderHandler:
|
||||
|
|
@ -253,6 +217,30 @@ services:
|
|||
$sub_key: "%env(MOTIV_KEY)%"
|
||||
$token: "%env(MOTIV_TOKEN)%"
|
||||
|
||||
# insurance connector
|
||||
App\Service\InsuranceConnector:
|
||||
arguments:
|
||||
$base_url: "%env(INSURANCE_BASE_URL)%"
|
||||
$username: "%env(INSURANCE_USERNAME)%"
|
||||
$password: "%env(INSURANCE_PASSWORD)%"
|
||||
|
||||
# entity listener for gateway transactions
|
||||
App\EntityListener\GatewayTransactionListener:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
$ic: "@App\\Service\\InsuranceConnector"
|
||||
tags:
|
||||
- name: doctrine.orm.entity_listener
|
||||
event: 'postUpdate'
|
||||
entity: 'App\Entity\GatewayTransaction'
|
||||
|
||||
# paymongo connector
|
||||
App\Service\PayMongoConnector:
|
||||
arguments:
|
||||
$base_url: "%env(PAYMONGO_BASE_URL)%"
|
||||
$public_key: "%env(PAYMONGO_PUBLIC_KEY)%"
|
||||
$secret_key: "%env(PAYMONGO_SECRET_KEY)%"
|
||||
|
||||
# entity listener for customer vehicle warranty code history
|
||||
App\EntityListener\CustomerVehicleSerialListener:
|
||||
arguments:
|
||||
|
|
@ -273,6 +261,14 @@ services:
|
|||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
# warranty logger for raffle
|
||||
App\Service\WarrantyRaffleLogger:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
# warranty raffle filter
|
||||
App\Service\WarrantyRaffleFilter: ~
|
||||
|
||||
# promo logger
|
||||
App\Service\PromoLogger:
|
||||
arguments:
|
||||
|
|
@ -301,3 +297,62 @@ services:
|
|||
App\Service\HubFilteringGeoChecker:
|
||||
arguments:
|
||||
$geofence_flag: "%env(HUB_GEOFENCE_ENABLE)%"
|
||||
|
||||
# bulk warranty uploader
|
||||
App\Service\WarrantyBulkUploader:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
# warranty serial file logger
|
||||
App\Service\WarrantySerialUploadLogger:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
# warranty serial load logger
|
||||
App\Service\WarrantySerialLoadLogger:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
# FCM sender
|
||||
App\Service\FCMSender:
|
||||
arguments:
|
||||
$server_key: "%env(FCM_SERVER_KEY)%"
|
||||
$sender_id: "%env(FCM_SENDER_ID)%"
|
||||
|
||||
# price tier manager
|
||||
App\Service\PriceTierManager:
|
||||
arguments:
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
|
||||
# hub filters
|
||||
App\Service\HubFilter\BaseHubFilter:
|
||||
arguments:
|
||||
$hub_filter_logger: "@App\\Service\\HubFilterLogger"
|
||||
$em: "@doctrine.orm.entity_manager"
|
||||
$rt: "@App\\Service\\RisingTideGateway"
|
||||
$trans: "@Symfony\\Contracts\\Translation\\TranslatorInterface"
|
||||
|
||||
App\Service\HubFilter\Filters\DateAndTimeHubFilter:
|
||||
public: true
|
||||
|
||||
App\Service\HubFilter\Filters\JoTypeHubFilter:
|
||||
public: true
|
||||
|
||||
App\Service\HubFilter\Filters\MaxResultsHubFilter:
|
||||
public: true
|
||||
|
||||
App\Service\HubFilter\Filters\PaymentMethodHubFilter:
|
||||
public: true
|
||||
|
||||
App\Service\HubFilter\Filters\RiderAvailabilityHubFilter:
|
||||
public: true
|
||||
|
||||
App\Service\HubFilter\Filters\InventoryHubFilter:
|
||||
public: true
|
||||
arguments:
|
||||
$im: "@App\\Service\\InventoryManager"
|
||||
|
||||
App\Service\HubFilter\Filters\RoundRobinHubFilter:
|
||||
public: true
|
||||
arguments:
|
||||
$hub_distributor: "@App\\Service\\HubDistributor"
|
||||
|
|
|
|||
|
|
@ -155,6 +155,30 @@ span.has-danger,
|
|||
color: #fff !important;
|
||||
}
|
||||
|
||||
.m-table__row--is_vip td {
|
||||
background-color: #ffff00 !important;
|
||||
color: #414a4c !important;
|
||||
}
|
||||
|
||||
.m-table__row--is_vip td > span,
|
||||
.m-table__row--is_vip td > span a,
|
||||
.m-table__row--is_vip td > span a i {
|
||||
color: #414a4c !important;
|
||||
}
|
||||
|
||||
.m-table__row--is_emergency td {
|
||||
background-color: #ffa500 !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.m-table__row--is_emergency td > span,
|
||||
.m-table__row--is_emergency td > span a,
|
||||
.m-table__row--is_emergency td > span a i {
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.m-datatable.m-datatable--default > .m-datatable__table {
|
||||
min-height: 0 !important;
|
||||
}
|
||||
|
|
@ -358,4 +382,4 @@ span.has-danger,
|
|||
|
||||
.map-info .m-badge {
|
||||
border-radius: 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
public/assets/images/image.gif
Executable file
|
After Width: | Height: | Size: 2.8 KiB |
74
public/assets/js/csv_export.js
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
$(function() {
|
||||
// export table to csv
|
||||
$(document).on('click', '[data-export-csv]', async function(e) {
|
||||
const el = e.target.closest('[data-export-csv]');
|
||||
const oldLabel = el.innerHTML;
|
||||
|
||||
// set loading status
|
||||
el.disabled = true;
|
||||
el.innerHTML = 'Exporting...';
|
||||
|
||||
const formData = new FormData();
|
||||
|
||||
formData.append('datatable[pagination][page]', 1);
|
||||
formData.append('datatable[pagination][perpage]', 10000000);
|
||||
|
||||
// get all rows
|
||||
const response = await fetch(el.dataset.url, {
|
||||
method: el.dataset.method,
|
||||
body: formData,
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.status === 200) {
|
||||
// empty set returned
|
||||
if (parseInt(result.meta.total) === 0) {
|
||||
swal({
|
||||
title: 'Whoops',
|
||||
html: 'No data to export!',
|
||||
type: 'warning',
|
||||
});
|
||||
}
|
||||
|
||||
// build csv data
|
||||
const csvRows = [];
|
||||
const fieldList = el.dataset.fields.split(',');
|
||||
csvRows.push(el.dataset.headers);
|
||||
|
||||
result.data.forEach((row) => {
|
||||
const fieldData = [];
|
||||
fieldList.forEach((field) => {
|
||||
fieldData.push('"' + row[field] + '"');
|
||||
});
|
||||
|
||||
csvRows.push(fieldData.join(','));
|
||||
});
|
||||
|
||||
const csvData = csvRows.join('\n');
|
||||
|
||||
// build the csv file
|
||||
const csvFile = new Blob([csvData], {
|
||||
type: 'text/csv',
|
||||
});
|
||||
|
||||
// create a link to the file and download it
|
||||
const url = window.URL.createObjectURL(csvFile);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = el.dataset.filename + '.csv';
|
||||
a.click();
|
||||
} else {
|
||||
// something went wrong on the server
|
||||
swal({
|
||||
title: 'Whoops',
|
||||
html: 'An error has occurred while retrieving data.',
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
|
||||
// remove loading status
|
||||
el.disabled = false;
|
||||
el.innerHTML = oldLabel;
|
||||
});
|
||||
});
|
||||
BIN
public/battery/enduro_mobile.jpg
Normal file → Executable file
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
BIN
public/battery/excel_mobile.jpg
Normal file → Executable file
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
BIN
public/battery/gold_mobile.jpg
Normal file → Executable file
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 13 KiB |
BIN
public/battery/premium_excel_mobile.jpg
Executable file
|
After Width: | Height: | Size: 14 KiB |
54
src/Command/CountTotalPendingWarrantySerialFilesCommand.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\WarrantySerialQueue;
|
||||
|
||||
class CountTotalPendingWarrantySerialFilesCommand extends Command
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('warrantyserial:count')
|
||||
->setDescription('Count number of pending warranty serial files.')
|
||||
->setHelp('Count number of pending warranty serial files.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
||||
$status = 'pending';
|
||||
|
||||
$db = $em->getConnection();
|
||||
|
||||
$ws_query_sql = 'SELECT COUNT(*) AS total FROM warranty_serial_queue
|
||||
WHERE status = :status';
|
||||
|
||||
$ws_query_stmt = $db->prepare($ws_query_sql);
|
||||
$ws_query_stmt->bindValue('status', $status);
|
||||
|
||||
$ws_results = $ws_query_stmt->executeQuery();
|
||||
|
||||
$results = $ws_results->fetchAssociative();
|
||||
|
||||
$output->write($results['total']);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Catalyst\APIBundle\Entity\User as APIUser;
|
||||
use Catalyst\APIBundle\Entity\Role as APIRole;
|
||||
use App\Entity\ApiUser as APIUser;
|
||||
use Catalyst\ApiBundle\Entity\Role as APIRole;
|
||||
|
||||
use App\Entity\Rider;
|
||||
|
||||
|
|
|
|||
529
src/Command/FulfillOpenJobOrderCommand.php
Normal file
|
|
@ -0,0 +1,529 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\JobOrder;
|
||||
use App\Entity\JOEvent;
|
||||
use App\Entity\User;
|
||||
use App\Entity\Warranty;
|
||||
use App\Entity\SAPBattery;
|
||||
|
||||
use App\Ramcar\JOStatus;
|
||||
use App\Ramcar\JOEventType;
|
||||
use App\Ramcar\DeliveryStatus;
|
||||
use App\Ramcar\WarrantyClass;
|
||||
use App\Ramcar\ServiceType;
|
||||
use App\Ramcar\WarrantySource;
|
||||
use App\Ramcar\WarrantyStatus;
|
||||
|
||||
use DateTime;
|
||||
use DateInterval;
|
||||
|
||||
class FulfillOpenJobOrderCommand extends Command
|
||||
{
|
||||
const DEFAULT_SAP_WARRANTY = 12;
|
||||
const JO_BATCH_CTR = 200;
|
||||
|
||||
protected $em;
|
||||
protected $batt_hash;
|
||||
protected $sap_batt_hash;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('joborder:fulfillopenjosnosms')
|
||||
->setDescription('Fulfill open job orders without sending an SMS message.')
|
||||
->setHelp('Mark open job orders as fulfilled and should not send a SMS message. Date format: YYYY-MM-DD')
|
||||
->addArgument('end_date', InputArgument::REQUIRED, 'End date. Format: YYYY-MM-DD');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
// load batteries into hash
|
||||
$this->populateBatteryIndex();
|
||||
|
||||
// load sap batteries into hash
|
||||
$this->populateSAPBatteryIndex();
|
||||
|
||||
// get the input date
|
||||
$str_date_end = $input->getArgument('end_date');
|
||||
|
||||
// append the 23:59:59 to end date
|
||||
$str_date_end = $str_date_end . ' ' . '23:59:59';
|
||||
|
||||
// starting time to count is date schedule
|
||||
$date_end = new DateTime($str_date_end);
|
||||
|
||||
// get current date and convert to string
|
||||
$current_date = new DateTime();
|
||||
$str_current_date = $current_date->format('Y-m-d H:i:s');
|
||||
|
||||
// find all open job orders starting from input date and before
|
||||
// need to get customer id, customer vehicle id, service type, warranty class
|
||||
$conn = $this->em->getConnection();
|
||||
|
||||
$jo_sql = 'SELECT jo.id AS jo_id, c.id AS c_id, cv.id AS cv_id,
|
||||
jo.service_type, jo.warranty_class, jo.rider_id, jo.date_schedule
|
||||
FROM job_order jo, customer c, customer_vehicle cv
|
||||
WHERE jo.customer_id = c.id AND jo.cvehicle_id = cv.id
|
||||
AND jo.status IN (\'pending\', \'rider_assign\', \'assigned\', \'in_transit\', \'in_progress\')
|
||||
AND jo.date_schedule <= :date_end';
|
||||
$stmt = $conn->prepare($jo_sql);
|
||||
$stmt->execute([
|
||||
'date_end' => $str_date_end]);
|
||||
|
||||
$jo_results = $stmt->fetchAll();
|
||||
|
||||
error_log('JOs found ' . count($jo_results));
|
||||
|
||||
$total_jos = count($jo_results);
|
||||
|
||||
$jo_ctr = 0;
|
||||
$update_jo_ctr = 0;
|
||||
$update_wheres = [];
|
||||
$w_data = [];
|
||||
$jo_evt_data = [];
|
||||
|
||||
foreach ($jo_results as $jo_row)
|
||||
{
|
||||
// get the data first
|
||||
$jo_id = $jo_row['jo_id'];
|
||||
$cust_id = $jo_row['c_id'];
|
||||
$cv_id = $jo_row['cv_id'];
|
||||
$service_type = $jo_row['service_type'];
|
||||
$warranty_class = $jo_row['warranty_class'];
|
||||
$rider_id = $jo_row['rider_id'];
|
||||
$str_date_schedule = $jo_row['date_schedule'];
|
||||
|
||||
$jo_ctr++;
|
||||
|
||||
// fulfill JO
|
||||
$this->fulfillJO($conn, $jo_id, $update_jo_ctr, $update_wheres, $jo_ctr, $total_jos);
|
||||
|
||||
// create JO event
|
||||
$jo_evt_data[] = $this->createJOEvent($conn, $jo_id, $str_current_date, $rider_id);
|
||||
|
||||
// error_log($jo_ctr . ' Processing JO ' . $jo_id);
|
||||
|
||||
// check service type
|
||||
if ($service_type == ServiceType::BATTERY_REPLACEMENT_NEW)
|
||||
{
|
||||
// new battery so we need to create warranty so we need to get battery id from invoice
|
||||
$batt_id = $this->getBatteryInformation($conn, $jo_id);
|
||||
|
||||
if (($batt_id != null) && (isset($this->batt_hash[$batt_id])))
|
||||
$w_data[] = $this->createWarrantyForJO($conn, $current_date, $str_date_schedule, $cust_id, $cv_id, $warranty_class, $batt_id);
|
||||
}
|
||||
}
|
||||
|
||||
// load data file for jo event
|
||||
$this->createLoadDataFileForJOEvent($jo_evt_data);
|
||||
|
||||
// load data file for warranty
|
||||
$this->createLoadDataFileForWarranty($w_data);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
protected function fulfillJO($conn, $jo_id, &$update_jo_ctr, &$update_wheres, $jo_ctr, $total_jos)
|
||||
{
|
||||
$update_wheres[] = 'id = ' . $jo_id;
|
||||
|
||||
// update db when we reach max # of JOs or when we reach total number of jos
|
||||
if (($update_jo_ctr == self::JO_BATCH_CTR) ||
|
||||
($jo_ctr == $total_jos))
|
||||
{
|
||||
error_log('Processing ' . $update_jo_ctr . ' job orders...');
|
||||
|
||||
$update_where_string = implode(' OR ' , $update_wheres);
|
||||
|
||||
// update job order
|
||||
$fulfill_jo_sql = 'UPDATE job_order SET status = :fulfilled, delivery_status = :del_fulfilled WHERE ' . $update_where_string;
|
||||
|
||||
// error_log($fulfill_jo_sql);
|
||||
|
||||
$fulfill_jo_stmt = $conn->prepare($fulfill_jo_sql);
|
||||
$fulfill_jo_stmt->execute([
|
||||
'fulfilled' => JOStatus::FULFILLED,
|
||||
'del_fulfilled' => DeliveryStatus::FULFILLED,
|
||||
]);
|
||||
|
||||
// reset the wheres string
|
||||
$update_wheres = [];
|
||||
|
||||
// reset the update jo counter
|
||||
$update_jo_ctr = 0;
|
||||
}
|
||||
else
|
||||
$update_jo_ctr++;
|
||||
}
|
||||
|
||||
protected function createJOEvent($conn, $jo_id, $str_current_date, $rider_id)
|
||||
{
|
||||
// create jo event
|
||||
// set user to admin that has id of 1
|
||||
$user_id = 1;
|
||||
|
||||
$r_id = '\N';
|
||||
// check if rider is null
|
||||
if ($rider_id != NULL)
|
||||
$r_id = $rider_id;
|
||||
|
||||
// create array for the jo event
|
||||
$data = [
|
||||
$user_id,
|
||||
$jo_id,
|
||||
$str_current_date,
|
||||
$str_current_date,
|
||||
JOEventType::FULFILL,
|
||||
$r_id,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function getBatteryInformation($conn, $jo_id)
|
||||
{
|
||||
// break this down into two sql calls
|
||||
// get the invoice for job order
|
||||
$i_sql = 'SELECT i.id FROM invoice i
|
||||
WHERE i.job_order_id = :jo_id';
|
||||
$i_stmt = $conn->prepare($i_sql);
|
||||
$i_stmt->execute([
|
||||
'jo_id' => $jo_id,
|
||||
]);
|
||||
|
||||
$i_result = $i_stmt->fetch();
|
||||
|
||||
// check if invoice exists
|
||||
if (empty($i_result))
|
||||
return null;
|
||||
|
||||
$invoice_id = $i_result['id'];
|
||||
|
||||
// get the battery id from invoice item
|
||||
$ii_sql = 'SELECT ii.battery_id FROM invoice_item ii
|
||||
WHERE ii.invoice_id = :invoice_id
|
||||
AND ii.battery_id IS NOT NULL';
|
||||
$ii_stmt = $conn->prepare($ii_sql);
|
||||
$ii_stmt->execute([
|
||||
'invoice_id' => $invoice_id,
|
||||
]);
|
||||
|
||||
$ii_result = $ii_stmt->fetch();
|
||||
|
||||
// checking for result
|
||||
if (empty($ii_result))
|
||||
return null;
|
||||
|
||||
$batt_id = $ii_result['battery_id'];
|
||||
|
||||
return $batt_id;
|
||||
}
|
||||
|
||||
protected function createWarrantyForJO($conn, $current_date, $str_date_schedule, $cust_id, $cv_id, $warranty_class, $batt_id)
|
||||
{
|
||||
// convert current date to string since we use this for date_create
|
||||
$str_current_date = $current_date->format('Y-m-d H:i:s');
|
||||
|
||||
// get the warranty period based on warranty class from battery hash
|
||||
$warranty_period = $this->getWarrantyPeriod($batt_id, $warranty_class);
|
||||
|
||||
// compute date expiry.
|
||||
// convert to DateTime date schedule
|
||||
$date_schedule = DateTime::createFromFormat('Y-m-d H:i:s', $str_date_schedule);
|
||||
$date_expire = $this->computeDateExpire($date_schedule, $warranty_period);
|
||||
|
||||
// convert to string the expiry date
|
||||
$str_date_expire = $date_expire->format('Y-m-d');
|
||||
|
||||
// convert date schedule to just date
|
||||
$str_date_purchase = $date_schedule->format('Y-m-d');
|
||||
|
||||
// check if date_expire is after or equal to the current date
|
||||
// if so, set warranty status to active
|
||||
$warranty_status = WarrantyStatus::EXPIRED;
|
||||
if ($date_expire >= $current_date)
|
||||
$warranty_status = WarrantyStatus::ACTIVE;
|
||||
|
||||
// get customer
|
||||
$cust_info = $this->getCustomerInfo($conn, $cust_id);
|
||||
|
||||
// get customer vehicle
|
||||
$cv_info = $this->getCustomerVehicleInfo($conn, $cv_id);
|
||||
|
||||
// customer info
|
||||
$first_name = addslashes($cust_info['first_name']);
|
||||
$last_name = addslashes($cust_info['last_name']);
|
||||
$mobile = addslashes($cust_info['mobile']);
|
||||
|
||||
// customer vehicle info
|
||||
$plate_number = $cv_info['plate_number'];
|
||||
$vehicle_id = $cv_info['vehicle_id'];
|
||||
|
||||
// battery info
|
||||
$model_id = $this->batt_hash[$batt_id]['model_id'];
|
||||
$size_id = $this->batt_hash[$batt_id]['size_id'];
|
||||
// need to confirm that sap_code exists in sap_battery
|
||||
if (isset($this->sap_batt_hash['sap_code']))
|
||||
$sap_code = $this->batt_hash[$batt_id]['sap_code'];
|
||||
else
|
||||
$sap_code = '\N';
|
||||
|
||||
// set flag_activated to false since that's the default in Warranty's constructor
|
||||
$flag_activated = false;
|
||||
|
||||
// create array for the infile
|
||||
$warranty_data = [
|
||||
$model_id,
|
||||
$size_id,
|
||||
$sap_code,
|
||||
$warranty_class,
|
||||
$plate_number,
|
||||
$warranty_status,
|
||||
$str_current_date,
|
||||
$str_date_purchase,
|
||||
$str_date_expire,
|
||||
$first_name,
|
||||
$last_name,
|
||||
$mobile,
|
||||
$flag_activated,
|
||||
$vehicle_id,
|
||||
$cust_id,
|
||||
WarrantySource::ADMIN_PANEL,
|
||||
];
|
||||
|
||||
return $warranty_data;
|
||||
}
|
||||
|
||||
protected function createLoadDataFileForWarranty($warranty_data)
|
||||
{
|
||||
// cache directory
|
||||
$cache_dir = __DIR__ . '/../../var/cache';
|
||||
|
||||
$file = $cache_dir . '/warranty_data.tab';
|
||||
error_log('opening file for warranty - ' . $file);
|
||||
|
||||
$fp = fopen($file, 'w');
|
||||
if ($fp === false)
|
||||
{
|
||||
error_log('could not open file for load data infile - ' . $file);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($warranty_data as $key => $data)
|
||||
{
|
||||
$line = implode('|', $data) . "\r\n";
|
||||
fwrite($fp, $line);
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
|
||||
error_log('Loading warranty data');
|
||||
$conn = $this->em->getConnection();
|
||||
$stmt = $conn->prepare('LOAD DATA LOCAL INFILE \'' . $file . '\' INTO TABLE warranty FIELDS TERMINATED BY \'|\' LINES TERMINATED BY \'\\r\\n\' (bty_model_id,bty_size_id,sap_bty_id,warranty_class,plate_number,status,date_create,date_purchase,date_expire,first_name,last_name,mobile_number,flag_activated,vehicle_id,customer_id, create_source)');
|
||||
$result = $stmt->execute();
|
||||
if (!$result)
|
||||
error_log('Failed loading data.');
|
||||
|
||||
// TODO: delete file?
|
||||
}
|
||||
|
||||
protected function createLoadDataFileForJOEvent($jo_evt_data)
|
||||
{
|
||||
// cache directory
|
||||
$cache_dir = __DIR__ . '/../../var/cache';
|
||||
|
||||
$file = $cache_dir . '/jo_event_data.tab';
|
||||
error_log('opening file for jo_event - ' . $file);
|
||||
|
||||
$fp = fopen($file, 'w');
|
||||
if ($fp === false)
|
||||
{
|
||||
error_log('could not open file for load data infile - ' . $file);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($jo_evt_data as $key => $data)
|
||||
{
|
||||
$line = implode('|', $data) . "\r\n";
|
||||
fwrite($fp, $line);
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
|
||||
error_log('Loading jo event data');
|
||||
$conn = $this->em->getConnection();
|
||||
$stmt = $conn->prepare('LOAD DATA LOCAL INFILE \'' . $file . '\' INTO TABLE jo_event FIELDS TERMINATED BY \'|\' LINES TERMINATED BY \'\\r\\n\' (create_user_id, job_order_id, date_create, date_happen, type_id, rider_id)');
|
||||
$result = $stmt->execute();
|
||||
if (!$result)
|
||||
error_log('Failed loading data.');
|
||||
|
||||
// TODO: delete file?
|
||||
}
|
||||
|
||||
protected function getCustomerInfo($conn, $id)
|
||||
{
|
||||
$cust_info = [];
|
||||
|
||||
$cust_sql = 'SELECT c.first_name, c.last_name, c.phone_mobile
|
||||
FROM customer c
|
||||
WHERE c.id = :id';
|
||||
$cust_stmt = $conn->prepare($cust_sql);
|
||||
$cust_stmt->execute([
|
||||
'id' => $id,
|
||||
]);
|
||||
|
||||
$cust_result = $cust_stmt->fetch();
|
||||
|
||||
$cust_info = [
|
||||
'first_name' => $cust_result['first_name'],
|
||||
'last_name' => $cust_result['last_name'],
|
||||
'mobile' => $cust_result['phone_mobile'],
|
||||
];
|
||||
|
||||
return $cust_info;
|
||||
}
|
||||
|
||||
protected function getCustomerVehicleInfo($conn, $id)
|
||||
{
|
||||
$cv_info = [];
|
||||
|
||||
$cv_sql = 'SELECT cv.plate_number, cv.vehicle_id
|
||||
FROM customer_vehicle cv
|
||||
WHERE cv.id = :id';
|
||||
$cv_stmt = $conn->prepare($cv_sql);
|
||||
$cv_stmt->execute([
|
||||
'id' => $id,
|
||||
]);
|
||||
|
||||
$cv_result = $cv_stmt->fetch();
|
||||
|
||||
$plate_number = $cv_result['plate_number'];
|
||||
|
||||
$clean_plate = $this->cleanPlateNumber($plate_number);
|
||||
|
||||
$cv_info = [
|
||||
'plate_number' => $clean_plate,
|
||||
'vehicle_id' => $cv_result['vehicle_id'],
|
||||
];
|
||||
|
||||
return $cv_info;
|
||||
}
|
||||
|
||||
protected function getWarrantyPeriod($batt_id, $warranty_class)
|
||||
{
|
||||
// set default period to that of private
|
||||
$period = $this->batt_hash[$batt_id]['warr_private'];
|
||||
|
||||
if ($warranty_class == WarrantyClass::WTY_PRIVATE)
|
||||
{
|
||||
$period = $this->batt_hash[$batt_id]['warr_private'];
|
||||
return $period;
|
||||
}
|
||||
if ($warranty_class == WarrantyClass::WTY_COMMERCIAL)
|
||||
{
|
||||
$period = $this->batt_hash[$batt_id]['warr_commercial'];
|
||||
return $period;
|
||||
}
|
||||
if ($warranty_class == WarrantyClass::WTY_TNV)
|
||||
{
|
||||
$period = $this->batt_hash[$batt_id]['warr_tnv'];
|
||||
return $period;
|
||||
}
|
||||
|
||||
return $period;
|
||||
}
|
||||
|
||||
protected function computeDateExpire($purchase_date, $warranty_period)
|
||||
{
|
||||
$expire_date = clone $purchase_date;
|
||||
$expire_date->add(new DateInterval('P'.$warranty_period.'M'));
|
||||
return $expire_date;
|
||||
}
|
||||
|
||||
protected function cleanPlateNumber($plate)
|
||||
{
|
||||
// trim plate number down to 20 characters
|
||||
$trim_plate = str_replace(' ','', $plate);
|
||||
|
||||
// truncate plate number down to 20 (max length)
|
||||
$trunc_plate = substr($trim_plate, 0, 20);
|
||||
|
||||
return strtoupper($trunc_plate);
|
||||
}
|
||||
|
||||
protected function populateBatteryIndex()
|
||||
{
|
||||
$conn = $this->em->getConnection();
|
||||
|
||||
// get all the batteries
|
||||
$sql = 'SELECT b.id, b.model_id, b.size_id, b.sap_code, b.warr_private, b.warr_commercial, b.warr_tnv
|
||||
FROM battery b';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
$results = $stmt->fetchAll();
|
||||
|
||||
// go through the rows
|
||||
foreach ($results as $row)
|
||||
{
|
||||
// breaking this down for clarity
|
||||
$battery_id = $row['id'];
|
||||
$model_id = $row['model_id'];
|
||||
$size_id = $row['size_id'];
|
||||
$sap_code = trim($row['sap_code']);
|
||||
$warr_private = $row['warr_private'];
|
||||
$warr_commercial = $row['warr_commercial'];
|
||||
$warr_tnv = $row['warr_tnv'];
|
||||
|
||||
$this->batt_hash[$battery_id] = [
|
||||
'sap_code' => $sap_code,
|
||||
'model_id' => $model_id,
|
||||
'size_id' => $size_id,
|
||||
'warr_private' => $warr_private,
|
||||
'warr_commercial' => $warr_commercial,
|
||||
'warr_tnv' => $warr_tnv,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
protected function populateSAPBatteryIndex()
|
||||
{
|
||||
$conn = $this->em->getConnection();
|
||||
|
||||
// get all the sap batteries
|
||||
$sql = 'SELECT sap.id, sap.brand_id, sap.size_id FROM sap_battery sap';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
$results = $stmt->fetchAll();
|
||||
|
||||
// go through the rows
|
||||
foreach ($results as $row)
|
||||
{
|
||||
// set warranty period to default warranty period for SAP batteries
|
||||
$this->sap_batt_hash[$row['id']] = [
|
||||
'sap_brand' => $row['brand_id'],
|
||||
'sap_size' => $row['size_id'],
|
||||
'warranty' => self::DEFAULT_SAP_WARRANTY,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ class GenerateBatteryCompatibilityCommand extends Command
|
|||
$vehicles = $vm->getVehicles();
|
||||
foreach ($vehicles as $vehicle)
|
||||
{
|
||||
$batteries = $vehicle->getBatteries();
|
||||
$batteries = $vehicle->getActiveBatteries();
|
||||
$comp_batt = [];
|
||||
foreach ($batteries as $battery)
|
||||
{
|
||||
|
|
|
|||
463
src/Command/ImportYokohamaVehicleBatteryCompatibilityCommand.php
Normal file
|
|
@ -0,0 +1,463 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||
use DateTime;
|
||||
|
||||
use App\Entity\VehicleManufacturer;
|
||||
use App\Entity\Vehicle;
|
||||
use App\Entity\Battery;
|
||||
use App\Entity\BatteryManufacturer;
|
||||
use App\Entity\BatteryModel;
|
||||
use App\Entity\BatterySize;
|
||||
|
||||
class ImportYokohamaVehicleBatteryCompatibilityCommand extends Command
|
||||
{
|
||||
const F_V_BRAND = 0;
|
||||
const F_V_MAKE = 1;
|
||||
const F_V_MODEL_YEAR = 2;
|
||||
const F_B_SIZE = 7;
|
||||
const F_B_MODEL = 8;
|
||||
//const F_B_ALT_PREM_MF = 10;
|
||||
//const F_B_ALT_PREM_LM = 11;
|
||||
//const F_B_ALT_SUPER_PREM_MF = 12;
|
||||
//const F_B_ALT_SUPREME_MF = 13;
|
||||
//const F_B_ALT_PLATINUM_MF = 14;
|
||||
// the rest of the fields are irrelevant
|
||||
|
||||
protected $em;
|
||||
protected $vmfg_index;
|
||||
protected $v_index;
|
||||
protected $batt_index;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->vmfg_index = [];
|
||||
$this->v_index = [];
|
||||
$this->batt_index = [];
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('yokohamavehicle:import')
|
||||
->setDescription('Import Yokohama data CSV file with vehicles and batteries.')
|
||||
->setHelp('Creates vehicles and batteries based on imported Yokohama CSV.')
|
||||
->addArgument('input_file', InputArgument::REQUIRED, 'Path to the CSV file.')
|
||||
->addArgument('output_file', InputArgument::REQUIRED, 'Path to output file.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$csv_file = $input->getArgument('input_file');
|
||||
$output_file = $input->getArgument('output_file');
|
||||
|
||||
$this->populateVehicleManufacturerIndex();
|
||||
$this->populateVehicleIndex();
|
||||
$this->populateBatteryIndex();
|
||||
|
||||
// attempt to open file
|
||||
try
|
||||
{
|
||||
$fh = fopen($csv_file, "r");
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception('The file "' . $csv_file . '" could be read.');
|
||||
}
|
||||
|
||||
// get entity manager
|
||||
$em = $this->em;
|
||||
|
||||
$vbrands = [];
|
||||
$output_info = [];
|
||||
|
||||
// loop through rows
|
||||
$row_num = 1;
|
||||
$prem_mf_name = '';
|
||||
$prem_lm_name = '';
|
||||
$super_prem_mf_name = '';
|
||||
$supreme_mf_name = '';
|
||||
$platinum_mf_name = '';
|
||||
while (($fields = fgetcsv($fh)) !== false)
|
||||
{
|
||||
$output->writeln("Parsing row " . $row_num . "...");
|
||||
|
||||
// alternate brands are not in file, so we just comment out
|
||||
// get the alternate battery brand header names
|
||||
/*
|
||||
if ($row_num == 2)
|
||||
{
|
||||
$prem_mf_name = $this->normalizeName($fields[SELF::F_B_ALT_PREM_MF]);
|
||||
$prem_lm_name = $this->normalizeName($fields[SELF::F_B_ALT_PREM_LM]);
|
||||
$super_prem_mf_name = $this->normalizeName($fields[SELF::F_B_ALT_SUPER_PREM_MF]);
|
||||
$supreme_mf_name = $this->normalizeName($fields[SELF::F_B_ALT_SUPREME_MF]);
|
||||
$platinum_mf_name = $this->normalizeName($fields[SELF::F_B_ALT_PLATINUM_MF]);
|
||||
}
|
||||
*/
|
||||
|
||||
// process row
|
||||
$output_info[] = $this->processRow($fields, $vbrands, $row_num, $prem_mf_name, $prem_lm_name,
|
||||
$super_prem_mf_name, $supreme_mf_name, $platinum_mf_name);
|
||||
|
||||
$row_num++;
|
||||
}
|
||||
|
||||
// save to db the valid ones
|
||||
foreach ($vbrands as $brand_name => $vbrand)
|
||||
{
|
||||
// vehicles
|
||||
foreach ($vbrand['vehicles'] as $row_num => $vdata)
|
||||
{
|
||||
$model = $vdata['model'];
|
||||
if ($model == 'NONE')
|
||||
{
|
||||
$m_year_from = 0;
|
||||
$m_year_to = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ex_model = explode('-', $model);
|
||||
$m_year_from = trim($ex_model[0]);
|
||||
|
||||
if (isset($ex_model[1]))
|
||||
$m_year_to = trim($ex_model[1]);
|
||||
else
|
||||
$m_year_to = 0;
|
||||
}
|
||||
|
||||
$vehicle = $this->v_index[$brand_name][$vdata['make'] . '|' . intval($m_year_from) . '|' . intval($m_year_to)];
|
||||
|
||||
// recommended battery
|
||||
$vdata['battery']->addVehicle($vehicle);
|
||||
|
||||
// alt_batteries
|
||||
// alternate brands are not in file, so we just comment out
|
||||
/*
|
||||
if (isset($vdata['alt_battery_prem_mf']))
|
||||
$vdata['alt_battery_prem_mf']->addVehicle($vehicle);
|
||||
if (isset($vdata['alt_battery_prem_lm']))
|
||||
$vdata['alt_battery_prem_lm']->addVehicle($vehicle);
|
||||
if (isset($vdata['alt_battery_super_prem_mf']))
|
||||
$vdata['alt_battery_super_prem_mf']->addVehicle($vehicle);
|
||||
if (isset($vdata['alt_battery_supreme_mf']))
|
||||
$vdata['alt_battery_supreme_mf']->addVehicle($vehicle);
|
||||
if (isset($vdata['alt_battery_platinum_mf']))
|
||||
$vdata['alt_battery_platinum_mf']->addVehicle($vehicle);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
// write to output file
|
||||
// error_log(print_r($output_info, true));
|
||||
$this->outputVehicleBatteryInfo($output_file, $output_info);
|
||||
|
||||
fclose($fh);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function processRow($fields, &$vbrands, $row_num, $prem_mf_name, $prem_lm_name,
|
||||
$super_prem_mf_name, $supreme_mf_name, $platinum_mf_nam)
|
||||
{
|
||||
$output_info = [];
|
||||
$brand = $this->normalizeName($fields[0]);
|
||||
$make = $this->normalizeName($fields[1]);
|
||||
$model = trim($fields[2]);
|
||||
$bsize = $this->normalizeName($fields[self::F_B_SIZE]);
|
||||
$bmodel = $this->normalizeName($fields[self::F_B_MODEL]);
|
||||
|
||||
// checking for valid vehicles and batteries should be done here so that only valid entries
|
||||
// go into the vbrands array
|
||||
$output_info = $this->validateManufacturerVehicle($fields, $brand, $make, $model, $bsize, $bmodel);
|
||||
|
||||
if (!empty($output_info))
|
||||
return $output_info;
|
||||
|
||||
if (!isset($vbrands[$brand]))
|
||||
{
|
||||
// build array
|
||||
$vbrands[$brand] = [
|
||||
'vehicles' => [],
|
||||
];
|
||||
}
|
||||
|
||||
if (empty($model))
|
||||
$model = 'NONE';
|
||||
|
||||
$vbrands[$brand]['vehicles'][$row_num] = [
|
||||
'make' => $make,
|
||||
'model' => $model,
|
||||
];
|
||||
|
||||
// at this point we are sure we have battery
|
||||
$batt_key = $this->getBatteryKey($bsize, $bmodel);
|
||||
$vbrands[$brand]['vehicles'][$row_num]['battery'] = $this->batt_index[$batt_key];
|
||||
|
||||
// alternate brands are not in file, so we just comment out
|
||||
// need to check alternate brands if battery exists
|
||||
// go through the alternate fields, look for 'P'. Not kidding. It's what is in the csv file.
|
||||
/*
|
||||
if ($this->normalizeName($fields[SELF::F_B_ALT_PREM_MF]) == 'P')
|
||||
{
|
||||
// check if we have battery for name + size combo
|
||||
$alt_batt_key = $this->getBatteryKey($field_bsize, $prem_mf_name);
|
||||
if (isset($this->batt_index[$alt_batt_key]))
|
||||
{
|
||||
$vbrands[$brand]['vehicles'][$row_num]['alt_battery_prem_mf'] = $this->batt_index[$alt_batt_key];
|
||||
}
|
||||
}
|
||||
if ($this->normalizeName($fields[SELF::F_B_ALT_PREM_LM]) == 'P')
|
||||
{
|
||||
// check if we have battery for name + size combo
|
||||
$alt_batt_key = $this->getBatteryKey($field_bsize, $prem_lm_name);
|
||||
if (isset($this->batt_index[$alt_batt_key]))
|
||||
{
|
||||
$vbrands[$brand]['vehicles'][$row_num]['alt_battery_prem_lm'] = $this->batt_index[$alt_batt_key];
|
||||
}
|
||||
}
|
||||
if ($this->normalizeName($fields[SELF::F_B_ALT_SUPER_PREM_MF]) == 'P')
|
||||
{
|
||||
// check if we have battery for name + size combo
|
||||
$alt_batt_key = $this->getBatteryKey($field_bsize, $super_prem_mf_name);
|
||||
if (isset($this->batt_index[$alt_batt_key]))
|
||||
{
|
||||
$vbrands[$brand]['vehicles'][$row_num]['alt_battery_super_prem_mf'] = $this->batt_index[$alt_batt_key];
|
||||
}
|
||||
}
|
||||
if ($this->normalizeName($fields[SELF::F_B_ALT_SUPREME_MF]) == 'P')
|
||||
{
|
||||
// check if we have battery for name + size combo
|
||||
$alt_batt_key = $this->getBatteryKey($field_bsize, $supreme_mf_name);
|
||||
if (isset($this->batt_index[$alt_batt_key]))
|
||||
{
|
||||
$vbrands[$brand]['vehicles'][$row_num]['alt_battery_supreme_mf'] = $this->batt_index[$alt_batt_key];
|
||||
}
|
||||
}
|
||||
if ($this->normalizeName($fields[SELF::F_B_ALT_PLATINUM_MF]) == 'P')
|
||||
{
|
||||
// check if we have battery for name + size combo
|
||||
$alt_batt_key = $this->getBatteryKey($field_bsize, $platinum_mf_name);
|
||||
if (isset($this->batt_index[$alt_batt_key]))
|
||||
{
|
||||
$vbrands[$brand]['vehicles'][$row_num]['alt_battery_platinum_mf'] = $this->batt_index[$alt_batt_key];
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
protected function validateManufacturerVehicle($fields, $brand, $make, $model, $bsize, $bmodel)
|
||||
{
|
||||
$output_info = [];
|
||||
|
||||
// check if manufacturer is blank
|
||||
if (empty($brand))
|
||||
{
|
||||
$message = 'No manufacturer provided.';
|
||||
$output_info = $this->setOutputInfo($fields, 'NOT ADDED', $message);
|
||||
return $output_info;
|
||||
}
|
||||
|
||||
// check if make is blank
|
||||
if (empty($make))
|
||||
{
|
||||
$message = 'No make provided.';
|
||||
$output_info = $this->setOutputInfo($fields, 'NOT ADDED', $message);
|
||||
return $output_info;
|
||||
}
|
||||
|
||||
// process model year data
|
||||
if ($model == 'NONE')
|
||||
{
|
||||
$m_year_from = 0;
|
||||
$m_year_to = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ex_model = explode('-', $model);
|
||||
$m_year_from = trim($ex_model[0]);
|
||||
|
||||
if (isset($ex_model[1]))
|
||||
$m_year_to = trim($ex_model[1]);
|
||||
else
|
||||
$m_year_to = 0;
|
||||
}
|
||||
|
||||
// get manufacturer or make one
|
||||
if (!isset($this->vmfg_index[$brand]))
|
||||
{
|
||||
// manufacturer
|
||||
$mfg = new VehicleManufacturer();
|
||||
$mfg->setName($brand);
|
||||
$this->em->persist($mfg);
|
||||
}
|
||||
else
|
||||
{
|
||||
$mfg = $this->vmfg_index[$brand];
|
||||
}
|
||||
|
||||
if (!isset($this->v_index[$brand][$make . '|' . intval($m_year_from) . '|' . intval($m_year_to)]))
|
||||
{
|
||||
// vehicle
|
||||
$vehicle = new Vehicle();
|
||||
$vehicle->setManufacturer($mfg)
|
||||
->setMake($make)
|
||||
->setModelYearFrom($m_year_from)
|
||||
->setModelYearTo($m_year_to);
|
||||
$this->em->persist($vehicle);
|
||||
}
|
||||
else
|
||||
{
|
||||
$vehicle = $this->v_index[$brand][$make . '|' . intval($m_year_from) . '|' . intval($m_year_to)];
|
||||
}
|
||||
|
||||
// save to db new manufacturer and vehicle
|
||||
$this->em->flush();
|
||||
|
||||
// add the vehicle manufacturer to hash
|
||||
$this->vmfg_index[$brand] = $mfg;
|
||||
|
||||
// add the new vehicle to hash
|
||||
$this->v_index[$brand][$make . '|' . $m_year_from . '|' . $m_year_to] = $vehicle;
|
||||
|
||||
// recommended battery
|
||||
$batt_key = $this->getBatteryKey($bsize, $bmodel);
|
||||
if (!isset($this->batt_index[$batt_key]))
|
||||
{
|
||||
$message = 'Could not find battery - ' . $bsize . ' - ' . $bmodel;
|
||||
$output_info = $this->setOutputInfo($fields, 'NOT ADDED', $message);
|
||||
return $output_info;
|
||||
}
|
||||
|
||||
return $output_info;
|
||||
}
|
||||
|
||||
protected function setOutputInfo($fields, $status, $reason)
|
||||
{
|
||||
$mfg_name = trim($fields[SELF::F_V_BRAND]);
|
||||
$model_name = trim($fields[SELF::F_V_MAKE]);
|
||||
$model_year = trim($fields[SELF::F_V_MODEL_YEAR]);
|
||||
$bsize = trim($fields[SELF::F_B_SIZE]);
|
||||
$bmodel = trim($fields[SELF::F_B_MODEL]);
|
||||
// alternate brands are not in file, so we just comment out
|
||||
/*
|
||||
$alt_prem_mf = trim($fields[SELF::F_B_ALT_PREM_MF]);
|
||||
$alt_prem_lm = trim($fields[SELF::F_B_ALT_PREM_LM]);
|
||||
$alt_super_prem_mf = trim($fields[SELF::F_B_ALT_SUPER_PREM_MF]);
|
||||
$alt_supreme_mf = trim($fields[SELF::F_B_ALT_SUPREME_MF]);
|
||||
$alt_platinum_mf = trim($fields[SELF::F_B_ALT_PLATINUM_MF]);
|
||||
*/
|
||||
|
||||
return [
|
||||
$mfg_name,
|
||||
$model_name,
|
||||
$model_year,
|
||||
$bsize,
|
||||
$bmodel,
|
||||
$status,
|
||||
$reason
|
||||
];
|
||||
}
|
||||
|
||||
protected function outputVehicleBatteryInfo($output_file, $entries)
|
||||
{
|
||||
try
|
||||
{
|
||||
$fh = fopen($output_file, "w");
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception('The file "' . $report_file . '" could be opened.');
|
||||
}
|
||||
|
||||
// write the headers
|
||||
fputcsv($fh, [
|
||||
'Manufacturer',
|
||||
'Vehicle Model',
|
||||
'Year Model',
|
||||
'Battery Size',
|
||||
'Battery Model',
|
||||
'Status',
|
||||
'Reason',
|
||||
]);
|
||||
|
||||
foreach($entries as $row)
|
||||
{
|
||||
if ($row != null)
|
||||
fputcsv($fh, $row);
|
||||
}
|
||||
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
protected function populateVehicleManufacturerIndex()
|
||||
{
|
||||
$vmfgs = $this->em->getRepository(VehicleManufacturer::class)->findAll();
|
||||
|
||||
$this->vmfg_index = [];
|
||||
|
||||
foreach ($vmfgs as $vmfg)
|
||||
{
|
||||
$mfg_name = $this->normalizeName($vmfg->getName());
|
||||
$this->vmfg_index[$mfg_name] = $vmfg;
|
||||
}
|
||||
}
|
||||
|
||||
protected function populateVehicleIndex()
|
||||
{
|
||||
$vs = $this->em->getRepository(Vehicle::class)->findAll();
|
||||
|
||||
$this->v_index = [];
|
||||
foreach ($vs as $v)
|
||||
{
|
||||
$mfg_name = $this->normalizeName($v->getManufacturer()->getName());
|
||||
if (!isset($this->v_index[$mfg_name]))
|
||||
$this->v_index[$mfg_name] = [];
|
||||
|
||||
$this->v_index[$mfg_name][$this->normalizeName($v->getMake()) . '|' . $v->getModelYearFrom() . '|' . $v->getModelYearTo()] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
protected function populateBatteryIndex()
|
||||
{
|
||||
$bs = $this->em->getRepository(Battery::class)->findAll();
|
||||
|
||||
$this->batt_index = [];
|
||||
foreach ($bs as $b)
|
||||
{
|
||||
// get the battery size
|
||||
$bsize = $b->getSize()->getName();
|
||||
|
||||
$key = $this->getBatteryKey($bsize, $b->getModel()->getName());
|
||||
|
||||
$this->batt_index[$key] = $b;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getBatteryKey($size_name, $model_name)
|
||||
{
|
||||
return $this->normalizeName(str_replace(' ', '', $size_name)) .
|
||||
'|' .
|
||||
$this->normalizeName(str_replace(' ', '', $model_name));
|
||||
}
|
||||
|
||||
protected function normalizeName($name)
|
||||
{
|
||||
$normalized_key = trim(strtoupper($name));
|
||||
|
||||
return $normalized_key;
|
||||
}
|
||||
|
||||
}
|
||||
469
src/Command/LoadWarrantySerialCommand.php
Normal file
|
|
@ -0,0 +1,469 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\WarrantySerial;
|
||||
use App\Entity\WarrantySerialQueue;
|
||||
use App\Entity\WarrantySerialUploadLog;
|
||||
use App\Entity\WarrantySerialLoadLog;
|
||||
|
||||
use App\Service\WarrantySerialUploadLogger;
|
||||
use App\Service\WarrantySerialLoadLogger;
|
||||
|
||||
use PDO;
|
||||
use DateTime;
|
||||
|
||||
class LoadWarrantySerialCommand extends Command
|
||||
{
|
||||
const FIELD_COUNT = 7;
|
||||
const SERIAL_LENGTH = 20;
|
||||
|
||||
protected $em;
|
||||
protected $upload_logger;
|
||||
protected $load_logger;
|
||||
protected $project_dir;
|
||||
protected $callback_url;
|
||||
protected $log_data;
|
||||
protected $filesystem;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, WarrantySerialUploadLogger $upload_logger,
|
||||
WarrantySerialLoadLogger $load_logger, KernelInterface $kernel, $callback_url,
|
||||
FileSystem $filesystem)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->upload_logger = $upload_logger;
|
||||
$this->load_logger = $load_logger;
|
||||
$this->project_dir = $kernel->getProjectDir();
|
||||
$this->callback_url = $callback_url;
|
||||
$this->filesystem = $filesystem;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('warrantyserial:load')
|
||||
->setDescription('Load warranty serials from file.')
|
||||
->setHelp('Load warranty serials from file.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$em = $this->em;
|
||||
$this->log_data = [];
|
||||
|
||||
$status = 'pending';
|
||||
|
||||
// get the filenames from the queue table with status pending
|
||||
$db = $em->getConnection();
|
||||
|
||||
$ws_query_sql = 'SELECT id, file_serial, file_id, api_user, orig_file_serial FROM warranty_serial_queue
|
||||
WHERE status = :status ORDER BY id LIMIT 1';
|
||||
|
||||
$ws_query_stmt = $db->prepare($ws_query_sql);
|
||||
$ws_query_stmt->bindValue('status', $status);
|
||||
|
||||
$ws_results = $ws_query_stmt->executeQuery();
|
||||
|
||||
$output_info = [];
|
||||
while ($row = $ws_results->fetchAssociative())
|
||||
{
|
||||
$filename = $row['file_serial'];
|
||||
$user_id = $row['api_user'];
|
||||
$id = $row['id'];
|
||||
$file_id = $row['file_id'];
|
||||
$orig_filename = $row['orig_file_serial'];
|
||||
|
||||
$output_info[] = $this->processWarrantySerialFile($filename, $user_id, $file_id, $orig_filename);
|
||||
|
||||
// remove entry from queue table
|
||||
$this->updateWarrantySerialQueue($id);
|
||||
|
||||
// delete the uploaded csv file and directory
|
||||
$this->deleteDirectoryAndFile($file_id);
|
||||
}
|
||||
|
||||
if (count($output_info) > 0)
|
||||
{
|
||||
// error_log(print_r($this->log_data, true));
|
||||
// load log data into db
|
||||
$this->load_logger->logWarrantySerialLoadInfo($this->log_data);
|
||||
|
||||
// send results back to third party
|
||||
$this->sendResults($output_info);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function processWarrantySerialFile($filename, $user_id, $file_id, $orig_filename)
|
||||
{
|
||||
$csv_file = $this->project_dir . '/public/warranty_serial_uploads/' . $filename;
|
||||
|
||||
$output_info = [];
|
||||
|
||||
// attempt to open file
|
||||
try
|
||||
{
|
||||
$fh = fopen($csv_file, "r");
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$error = 'The file ' . $csv_file . 'could not be read.';
|
||||
$log_data = [
|
||||
'user_id' => $user_id,
|
||||
'is_uploaded' => false,
|
||||
'error' => $error,
|
||||
];
|
||||
$this->upload_logger->logWarrantySerialUploadInfo($log_data);
|
||||
|
||||
$output_info = $this->setOutputInfo($filename, $file_id, true, $error, $data, $orig_filename);
|
||||
|
||||
return $output_info;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
while(($row = fgetcsv($fh)) !== false)
|
||||
{
|
||||
$validation_result = $this->validateRow($row, $user_id);
|
||||
if (!empty($validation_result))
|
||||
{
|
||||
$data[] = $validation_result;
|
||||
continue;
|
||||
}
|
||||
|
||||
// valid entry, we parse and insert
|
||||
$serial = trim(strtoupper($row[0]));
|
||||
|
||||
// error_log('Processing ' . $serial);
|
||||
|
||||
$sku = trim(strtoupper($row[1]));
|
||||
$dispatch_status = trim($row[2]);
|
||||
$str_date_create = trim($row[3]);
|
||||
$inventory_status = trim($row[4]);
|
||||
$cat_id = trim($row[5]);
|
||||
$cat_name = trim(strtoupper($row[6]));
|
||||
|
||||
// we are sure that this is a valid date at this point
|
||||
$created_date = $this->convertDateCreate($str_date_create);
|
||||
|
||||
$meta_info = [
|
||||
'dispatch_status' => $dispatch_status,
|
||||
'inventory_status' => $inventory_status,
|
||||
'category_id' => $cat_id,
|
||||
'category_name' => $cat_name,
|
||||
];
|
||||
|
||||
$info = json_encode($meta_info);
|
||||
|
||||
// prepare the data
|
||||
$source = 'motiv';
|
||||
if ($sku == 'N/A')
|
||||
$sku = null;
|
||||
|
||||
// prepared statement
|
||||
$db = $this->em->getConnection();
|
||||
$insert_stmt = $db->prepare('INSERT INTO warranty_serial (id, sku, date_create, source, meta_info)
|
||||
VALUES (:serial, :sku, :date_create, :source, :meta_info)');
|
||||
|
||||
$res = $insert_stmt->execute([
|
||||
':serial' => $serial,
|
||||
':sku' => $sku,
|
||||
':date_create' => $created_date,
|
||||
':source' => $source,
|
||||
':meta_info' => $info,
|
||||
]);
|
||||
|
||||
if (!$res)
|
||||
{
|
||||
// log the not successful insert
|
||||
$err = $insert_stmt->errorInfo();
|
||||
$error = $err[2];
|
||||
$this->logLoadInfo($user_id, false, $serial, $error);
|
||||
|
||||
$data[] = [
|
||||
'serial' => $serial,
|
||||
'status' => 'error',
|
||||
'has_error' => true,
|
||||
'error_message' => $error,
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
// log the successful insert
|
||||
$this->logLoadInfo($user_id, true, $serial, '');
|
||||
|
||||
$data[] = [
|
||||
'serial' => $serial,
|
||||
'status' => 'success',
|
||||
'has_error' => false,
|
||||
'error_message' => '',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// form what we output
|
||||
$output_info = $this->setOutputInfo($filename, $file_id, false, '', $data, $orig_filename, $orig_filename);
|
||||
|
||||
return $output_info;
|
||||
}
|
||||
|
||||
protected function validateRow($row, $user_id)
|
||||
{
|
||||
$data = [];
|
||||
// possible lines:
|
||||
// (1) header in csv file - ignore
|
||||
// SerialNumber,Sku,DispatchStatus,CreatedDate,InventoryStatus,CategoryID,CategoryName
|
||||
// (2) No available data - ignore
|
||||
// (3) CH2000012071,WCHD23BL-CPN00-LX,0,2020-08-11 04:05:27.090,0,4,CHAMPION MF - valid
|
||||
// (4) MG2000313690,N/A,1,2021-05-14T23:47:30.6430000+08:00,0,10,GOLD - valid
|
||||
// (5) Empty line - ignore
|
||||
// (6) empty sku - log
|
||||
|
||||
// check if empty line
|
||||
if ($row == array(null))
|
||||
{
|
||||
// no need to log, but send back error
|
||||
$error = 'Empty line';
|
||||
$data = [
|
||||
'serial' => '',
|
||||
'status' => 'error',
|
||||
'has_error' => true,
|
||||
'error_message' => $error,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// check the number of fields
|
||||
if (count($row) != self::FIELD_COUNT)
|
||||
{
|
||||
$error = 'Invalid number of fields.';
|
||||
$data = [
|
||||
'serial' => '',
|
||||
'status' => 'error',
|
||||
'has_error' => true,
|
||||
'error_message' => $error,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// check if the line is a header
|
||||
if ($row[0] == 'SerialNumber')
|
||||
{
|
||||
// no need to log, but send back error
|
||||
$error = 'Invalid information.';
|
||||
$data = [
|
||||
'serial' => '',
|
||||
'status' => 'error',
|
||||
'has_error' => true,
|
||||
'error_message' => $error,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// check if empty serial
|
||||
if (empty($row[0]))
|
||||
{
|
||||
// this one, we log
|
||||
$error = 'Empty serial';
|
||||
$this->logLoadInfo($user_id, false, '', $error);
|
||||
|
||||
$data = [
|
||||
'serial' => '',
|
||||
'status' => 'error',
|
||||
'has_error' => true,
|
||||
'error_message' => $error,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// check length of serial
|
||||
$serial = trim($row[0]);
|
||||
if (strlen($serial) > SELF::SERIAL_LENGTH)
|
||||
{
|
||||
// log
|
||||
$error = 'Serial length too long';
|
||||
$this->logLoadInfo($user_id, false, $serial, $error);
|
||||
|
||||
$data = [
|
||||
'serial' => $serial,
|
||||
'status' => 'error',
|
||||
'has_error' => true,
|
||||
'error_message' => $error,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// validate the date created
|
||||
$str_date_create = trim($row[3]);
|
||||
|
||||
$date_create = $this->convertDateCreate($str_date_create);
|
||||
if ($date_create == null)
|
||||
{
|
||||
// log
|
||||
$error = 'Invalid date create.';
|
||||
$this->logLoadInfo($user_id, false, $serial, $error);
|
||||
|
||||
$data = [
|
||||
'serial' => $serial,
|
||||
'status' => 'error',
|
||||
'has_error' => true,
|
||||
'error_message' => $error,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// check if serial is a dupe
|
||||
$existing_serial = $this->em->getRepository(WarrantySerial::class)->find($serial);
|
||||
if ($existing_serial != null)
|
||||
{
|
||||
// log
|
||||
$error = 'Serial already exists.';
|
||||
$this->logLoadInfo($user_id, false, $serial, $error);
|
||||
|
||||
$data = [
|
||||
'serial' => $serial,
|
||||
'status' => 'error',
|
||||
'has_error' => true,
|
||||
'error_message' => $error,
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
// valid entry, return empty
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function convertDateCreate($str_date_create)
|
||||
{
|
||||
// since some people cannot follow simple instructions...
|
||||
// check the date format on the string
|
||||
// try 2021-05-15T08:35:46+08:00 format on str_date_create
|
||||
$date_create = DateTime::createFromFormat('Y-m-d\TH:i:sP', $str_date_create);
|
||||
|
||||
if ($date_create == false)
|
||||
{
|
||||
// try this format: 2021-05-15T08:47:20.3330000+08:00
|
||||
// get the date, time and timezone from str_date_create
|
||||
$str_date_time = substr($str_date_create, 0, 19);
|
||||
$str_timezone = substr($str_date_create, 27);
|
||||
$str_datetime_tz = $str_date_time . $str_timezone;
|
||||
|
||||
// create DateTime object
|
||||
// sample: 2021-05-15T12:16:06+08:00
|
||||
$date_create = DateTime::createFromFormat('Y-m-d\TH:i:sP', $str_datetime_tz);
|
||||
|
||||
// check if datetime object was created
|
||||
// if not, someone f*cked up and we have no date create
|
||||
if ($date_create == false)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// if you reach this part, then date string is valid. Since we'll be using
|
||||
// sql to insert the entries, we return the string
|
||||
$created_date = $date_create->format('Y-m-d H:i:s');
|
||||
// $created_date = DateTime::createFromFormat('Y-m-d H:i:s', $str_created_date);
|
||||
|
||||
return $created_date;
|
||||
}
|
||||
|
||||
protected function logLoadInfo($user_id, $is_loaded, $serial, $error)
|
||||
{
|
||||
$date_create = new DateTime();
|
||||
$str_date_create = $date_create->format('Y-m-d H:i:s');
|
||||
|
||||
$this->log_data[] = [
|
||||
$str_date_create,
|
||||
$user_id,
|
||||
$serial,
|
||||
$is_loaded,
|
||||
$error,
|
||||
];
|
||||
}
|
||||
|
||||
protected function updateWarrantySerialQueue($id)
|
||||
{
|
||||
// prepared statement
|
||||
$db = $this->em->getConnection();
|
||||
|
||||
// lock the warranty serial queue table
|
||||
$db->exec('LOCK TABLES warranty_serial_queue WRITE;');
|
||||
|
||||
$delete_stmt = $db->prepare('DELETE FROM warranty_serial_queue
|
||||
WHERE id = :id');
|
||||
|
||||
$res = $delete_stmt->execute([
|
||||
':id' => $id,
|
||||
]);
|
||||
|
||||
$db->exec('UNLOCK TABLES;');
|
||||
}
|
||||
|
||||
protected function deleteDirectoryAndFile($filedir)
|
||||
{
|
||||
$csv_filedir = $this->project_dir . '/public/warranty_serial_uploads/' . $filedir;
|
||||
|
||||
$this->filesystem->remove($csv_filedir);
|
||||
}
|
||||
|
||||
protected function setOutputInfo($filename, $file_id, $has_error, $error_message, $entries, $orig_filename)
|
||||
{
|
||||
$info = [
|
||||
'id' => $file_id,
|
||||
'filename' => $orig_filename,
|
||||
'has_error' => $has_error,
|
||||
'error_message' => $error_message,
|
||||
'data' => $entries,
|
||||
];
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
protected function sendResults($output_info)
|
||||
{
|
||||
$body = json_encode($output_info);
|
||||
|
||||
// error_log(print_r($body, true));
|
||||
|
||||
// error_log('Sending json output to ' . $this->callback_url);
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
$options = [
|
||||
CURLOPT_URL => $this->callback_url,
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_POSTFIELDS => $body,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
'Content-Type: application/json',
|
||||
],
|
||||
];
|
||||
|
||||
curl_setopt_array($curl, $options);
|
||||
$res = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
// check result
|
||||
error_log('Result ' . $res);
|
||||
}
|
||||
|
||||
}
|
||||
136
src/Command/ProcessLatePaymongoTransactionsCommand.php
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Ramcar\TransactionStatus;
|
||||
use App\Entity\GatewayTransaction;
|
||||
use App\Service\PayMongoConnector;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class ProcessLatePaymongoTransactionsCommand extends Command
|
||||
{
|
||||
protected $em;
|
||||
protected $paymongo;
|
||||
|
||||
protected $webhook_id;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, PayMongoConnector $paymongo, $webhook_id)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->paymongo = $paymongo;
|
||||
$this->webhook_id = $webhook_id;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('paymongo:checkpending')
|
||||
->setDescription('Check for any late PayMongo transactions and process if needed.')
|
||||
->setHelp('Check for any late PayMongo transactions and process if needed.')
|
||||
->addOption('force', 'f', InputOption::VALUE_NONE, 'Ignore webhook status and process anyway.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$force = $input->getOption('force');
|
||||
|
||||
// if we aren't forcing, check webhook status first
|
||||
if (!$force) {
|
||||
$output->writeln('Checking webhook status...');
|
||||
|
||||
// check if webhook is disabled
|
||||
$webhook = $this->paymongo->getWebhook($this->webhook_id);
|
||||
|
||||
if ($webhook['success'] && $webhook['response']['data']['attributes']['status'] === 'enabled') {
|
||||
$output->writeln('<info>Webhook is enabled, no need to do anything.</info>');
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
$output->writeln('<comment>Webhook is disabled! Logging event and attempting to re-enable...</comment>');
|
||||
|
||||
// attempt re-enabling of webhook
|
||||
$result = $this->paymongo->enableWebhook($this->webhook_id);
|
||||
if ($result['success'] && $result['response']['data']['attributes']['status'] ?? null === 'enabled') {
|
||||
$output->writeln('<info>Webhook ' . $this->webhook_id . ' re-enabled!</info>');
|
||||
|
||||
// log event
|
||||
$this->paymongo->log('WEBHOOK RE-ENABLED', "[]", json_encode($result['response'], JSON_PRETTY_PRINT), 'webhook');
|
||||
} else {
|
||||
$output->writeln('<comment>Webhook ' . $this->webhook_id . ' could not be re-enabled.</comment>');
|
||||
|
||||
// log event
|
||||
$this->paymongo->log('WEBHOOK FAILURE', "[]", json_encode($result['response'], JSON_PRETTY_PRINT), 'webhook');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('Fetching all late pending transactions...');
|
||||
|
||||
// set date threshold to 24 hours ago
|
||||
$date_threshold = (new DateTime())->modify('-24 hours');
|
||||
|
||||
$transactions = $this->em->getRepository(GatewayTransaction::class)
|
||||
->createQueryBuilder('t')
|
||||
->select('t')
|
||||
->where('t.status = :status')
|
||||
->andWhere('t.date_create <= :date_threshold')
|
||||
->setParameter('status', TransactionStatus::PENDING)
|
||||
->setParameter('date_threshold', $date_threshold)
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
$output->writeln('Found '. count($transactions) . ' rows matching criteria.');
|
||||
|
||||
$x = 0;
|
||||
|
||||
foreach ($transactions as $trans) {
|
||||
// check paymongo status
|
||||
$checkout = $this->paymongo->getCheckout($trans->getExtTransactionId());
|
||||
|
||||
if ($checkout['success']) {
|
||||
// check if we have any payments made
|
||||
$payments = $checkout['response']['data']['attributes']['payments'] ?? [];
|
||||
|
||||
if (!empty($payments)) {
|
||||
$amount_paid = 0;
|
||||
|
||||
// for good measure, we get all successful payments and add them up
|
||||
foreach ($payments as $payment) {
|
||||
if ($payment['attributes']['status'] === TransactionStatus::PAID) {
|
||||
$amount_paid = bcadd($amount_paid, $payment['attributes']['amount']);
|
||||
}
|
||||
}
|
||||
|
||||
// this transaction is fully paid, so we mark it as paid
|
||||
if (bccomp($trans->getAmount(), $amount_paid) <= 0) {
|
||||
$trans->setStatus(TransactionStatus::PAID);
|
||||
$trans->setDatePay(new DateTime());
|
||||
$this->em->flush();
|
||||
|
||||
$output->writeln('Marked transaction '. $trans->getID() . ' as paid.');
|
||||
$x++;
|
||||
} else {
|
||||
$output->writeln('<comment>Insufficient payment amount (' . $amount_paid . '/' . $trans->getAmount() . ') for this transaction: ' . $trans->getID() . '</comment>');
|
||||
}
|
||||
} else {
|
||||
$output->writeln('<comment>No payments found for transaction: ' . $trans->getID() . '</comment>');
|
||||
}
|
||||
} else {
|
||||
$output->writeln('<comment>Checkout not found: ' . $checkout['error']['message'] . '</comment>');
|
||||
}
|
||||
}
|
||||
|
||||
$output->writeln('<info>Done! Processed ' . $x . ' rows.</info>');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
80
src/Command/SetJobOrderCustNewCommand.php
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Service\JobOrderManager;
|
||||
|
||||
class SetJobOrderCustNewCommand extends Command
|
||||
{
|
||||
protected $em;
|
||||
protected $jo_manager;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, JobOrderManager $jo_manager)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->jo_manager = $jo_manager;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('joborder:setcustomernew')
|
||||
->setDescription('Set job order\'s customer new flag for existing job orders.')
|
||||
->setHelp('Set job order\'s customer new flag for existing job orders');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$em = $this->em;
|
||||
|
||||
// pdo connection
|
||||
$db = $em->getConnection();
|
||||
|
||||
// get all the ids for all job orders
|
||||
$all_query_sql = 'SELECT id AS jo_id, customer_id AS cust_id FROM job_order ORDER BY id';
|
||||
|
||||
$all_query_stmt = $db->prepare($all_query_sql);
|
||||
$all_query_stmt->execute();
|
||||
|
||||
$all_jo_results = $all_query_stmt->fetchAll();
|
||||
|
||||
$output->writeln('Processing job orders...');
|
||||
|
||||
foreach ($all_jo_results as $jo_row)
|
||||
{
|
||||
// for each jo id, get the customer id
|
||||
$jo_id = $jo_row['jo_id'];
|
||||
$cust_id = $jo_row['cust_id'];
|
||||
|
||||
// check how many JOs have that customer id
|
||||
$jo_count = $this->jo_manager->getCustomerJobOrderCount($cust_id);
|
||||
|
||||
// if one or less, set flag_cust_new to true
|
||||
if ($jo_count <= 1)
|
||||
$this->updateCustNew($db, $jo_id);
|
||||
}
|
||||
|
||||
$output->writeln('All done!');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function updateCustNew($db, $jo_id)
|
||||
{
|
||||
$update_jo_sql = 'UPDATE job_order SET flag_cust_new = :flag_cust_new WHERE id = :jo_id';
|
||||
|
||||
$update_jo_stmt = $db->prepare($update_jo_sql);
|
||||
$update_jo_stmt->execute([
|
||||
'flag_cust_new' => true,
|
||||
'jo_id' => $jo_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
54
src/Command/TestClosestOpenHubsCommand.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||
|
||||
use App\Service\MapTools;
|
||||
|
||||
class TestClosestOpenHubsCommand extends Command
|
||||
{
|
||||
protected $maptools;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('test:closestopenhubs')
|
||||
->setDescription('Test the get closest open hubs service.')
|
||||
->setHelp('Test the get closese open hubs service.')
|
||||
->addArgument('long', InputArgument::REQUIRED, 'Longitude')
|
||||
->addArgument('lat', InputArgument::REQUIRED, 'Latitude');
|
||||
}
|
||||
|
||||
public function __construct(MapTools $maptools)
|
||||
{
|
||||
$this->maptools = $maptools;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$long = $input->getArgument('long');
|
||||
$lat = $input->getArgument('lat');
|
||||
|
||||
$point = new Point($long, $lat);
|
||||
|
||||
$hubs_with_distance = $this->maptools->getClosestOpenHubs($point, 10);
|
||||
|
||||
foreach($hubs_with_distance as $hub_dist)
|
||||
{
|
||||
$hub = $hub_dist['hub'];
|
||||
$distance = $hub_dist['distance'];
|
||||
|
||||
error_log('Hub ID ' . $hub->getID() . ' - ' . $hub->getName() . ' = ' . $distance . ' kms away.');
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
44
src/Command/TestHashGeneratorCommand.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use App\Service\HashGenerator;
|
||||
|
||||
class TestHashGeneratorCommand extends Command
|
||||
{
|
||||
protected $hash;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('test:hash')
|
||||
->setDescription('Test hash generator.')
|
||||
->setHelp('Test hash generator service.');
|
||||
}
|
||||
|
||||
public function __construct(HashGenerator $hash)
|
||||
{
|
||||
$this->hash = $hash;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$orig_id = 39095;
|
||||
error_log('original id - ' . $orig_id);
|
||||
|
||||
$hash_id = $this->hash->getHash($orig_id);
|
||||
error_log('hash id - ' . $hash_id);
|
||||
|
||||
$id = $this->hash->getID($hash_id);
|
||||
error_log('id - ' . $id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
2106
src/Command/TestInvoiceManagerCommand.php
Normal file
|
|
@ -7,11 +7,14 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use App\Service\RisingTideGateway;
|
||||
|
||||
class TestSMSCommand extends Command
|
||||
{
|
||||
protected $gateway;
|
||||
protected $translator;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
|
|
@ -21,9 +24,10 @@ class TestSMSCommand extends Command
|
|||
->addArgument('destination', InputArgument::REQUIRED, 'Destination number to send to');
|
||||
}
|
||||
|
||||
public function __construct(RisingTideGateway $gateway)
|
||||
public function __construct(RisingTideGateway $gateway, TranslatorInterface $translator)
|
||||
{
|
||||
$this->gateway = $gateway;
|
||||
$this->translator = $translator;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
|
@ -34,7 +38,7 @@ class TestSMSCommand extends Command
|
|||
|
||||
error_log('sending sms to ' . $number);
|
||||
$msg = 'This is a test.';
|
||||
$this->gateway->sendSMS($number, 'MOTOLITE', $msg);
|
||||
$this->gateway->sendSMS($number, $this->translator->trans('message.battery_brand_allcaps'), $msg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
464
src/Command/TestWarrantyUploadCommand.php
Normal file
|
|
@ -0,0 +1,464 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Ramcar\WarrantySource;
|
||||
use App\Ramcar\WarrantyStatus;
|
||||
use App\Ramcar\WarrantyClass;
|
||||
|
||||
use DateTime;
|
||||
use DateInterval;
|
||||
use PDO;
|
||||
|
||||
class TestWarrantyUploadCommand extends Command
|
||||
{
|
||||
const F_ENCODER = 0;
|
||||
const F_DATE_ENCODED = 1;
|
||||
const F_FNAME = 2;
|
||||
const F_LNAME = 3;
|
||||
const F_EMAIL = 4;
|
||||
const F_ADDRESS = 5;
|
||||
const F_MOBILE = 6;
|
||||
const F_TELEPHONE = 7;
|
||||
const F_VMAKE = 8;
|
||||
const F_VMODEL = 9;
|
||||
const F_MYEAR = 10;
|
||||
const F_PLATE_NUMBER = 11;
|
||||
const F_SERIAL = 12;
|
||||
const F_INVOICE_NUM = 13;
|
||||
const F_DATE_PURCHASE = 14;
|
||||
const F_DIST_NAME = 15;
|
||||
const F_DIST_ADDRESS = 16;
|
||||
const F_APP_TYPE_ID = 17;
|
||||
const F_BATT_ID = 18; // sap code in system
|
||||
const F_OWNER_TYPE = 19;
|
||||
|
||||
protected $em;
|
||||
protected $batt_hash;
|
||||
protected $sap_batt_hash;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('testwarranty:upload')
|
||||
->setDescription('Test bulk warranty upload.')
|
||||
->setHelp('Test bulk warranty upload.')
|
||||
->addArgument('input_file', InputArgument::REQUIRED, 'Path to the CSV file.')
|
||||
->addArgument('output_file', InputArgument::REQUIRED, 'Path to output file.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
// hash the battery table using sap_code as index
|
||||
$this->populateBatteryIndex();
|
||||
|
||||
$csv_file = $input->getArgument('input_file');
|
||||
$output_file = $input->getArgument('output_file');
|
||||
|
||||
// attempt to open file
|
||||
try
|
||||
{
|
||||
$fh = fopen($csv_file, "r");
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception('The file "' . $csv_file . '" could be read.');
|
||||
}
|
||||
|
||||
$output_info = [];
|
||||
|
||||
// loop through rows
|
||||
// ignore first row since that's header data
|
||||
$row_num = 0;
|
||||
|
||||
$sql_values = '';
|
||||
while (($fields = fgetcsv($fh)) !== false)
|
||||
{
|
||||
// ignore first row since that's the header
|
||||
if ($row_num == 0)
|
||||
{
|
||||
$row_num++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// process row
|
||||
$output_info[] = $this->processRow($fields, $sql_values);
|
||||
|
||||
$row_num++;
|
||||
}
|
||||
|
||||
// check if we have values to insert
|
||||
if (strlen($sql_values) > 0)
|
||||
{
|
||||
$sql_statement = 'INSERT INTO `warranty` (bty_model_id,bty_size_id,sap_bty_id,serial,warranty_class,plate_number,status,date_create,date_purchase,date_expire,first_name,last_name,mobile_number,flag_activated,vehicle_id,customer_id, create_source) VALUES ' . $sql_values . ';' . "\n";
|
||||
|
||||
// error_log($sql_statement);
|
||||
|
||||
$conn = $this->em->getConnection();
|
||||
$stmt = $conn->prepare($sql_statement);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
// write to output file
|
||||
$this->outputWarrantyInfo($output_file, $output_info);
|
||||
|
||||
fclose($fh);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function processRow($fields, &$sql_values)
|
||||
{
|
||||
error_log('Processing warranty with serial ' . trim($fields[self::F_SERIAL]));
|
||||
|
||||
$output_info = [];
|
||||
|
||||
// get necessary fields
|
||||
$fname = trim($fields[self::F_FNAME]);
|
||||
$lname = trim($fields[self::F_LNAME]);
|
||||
$mobile = trim($fields[self::F_MOBILE]);
|
||||
$serial = trim($fields[self::F_SERIAL]);
|
||||
$date_purchase = trim($fields[self::F_DATE_PURCHASE]);
|
||||
$sap_code = trim($fields[self::F_BATT_ID]);
|
||||
$plate_number = $this->cleanPlateNumber($fields[self::F_PLATE_NUMBER]);
|
||||
|
||||
// validate the necessary fields
|
||||
$output_info = $this->validateFields($fields);
|
||||
if (!empty($output_info))
|
||||
return $output_info;
|
||||
|
||||
// see if we can get customer id and vehicle id, given the plate number.
|
||||
// this is not required so if we can't find customer and/or vehicle,
|
||||
// we still create the warranty
|
||||
$conn = $this->em->getConnection();
|
||||
|
||||
// NOTE: what happens if there's more than one result?
|
||||
// for now, get the first one
|
||||
$sql = 'SELECT c.id AS c_id, v.id AS v_id FROM customer_vehicle cv, customer c, vehicle v
|
||||
WHERE cv.customer_id = c.id AND cv.vehicle_id = v.id AND cv.plate_number = :plate_number LIMIT 1';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute(['plate_number' => $plate_number]);
|
||||
|
||||
$cv_results = $stmt->fetch();
|
||||
|
||||
$cust_id = 'NULL';
|
||||
$vehicle_id = 'NULL';
|
||||
if (!empty($cv_results))
|
||||
{
|
||||
$cust_id = $cv_results['c_id'];
|
||||
$vehicle_id = $cv_results['v_id'];
|
||||
}
|
||||
|
||||
// get battery info from hash (battery model id, battery size id, warranty periods (needed for expiration date)
|
||||
$batt_info = $this->batt_hash[$sap_code];
|
||||
$b_id = $batt_info['id'];
|
||||
$model_id = $batt_info['model_id'];
|
||||
$size_id = $batt_info['size_id'];
|
||||
$warr_private = $batt_info['warr_private'];
|
||||
$warr_commercial = $batt_info['warr_commercial'];
|
||||
$warr_tnv = $batt_info['warr_tnv'];
|
||||
|
||||
// format purchase date to DateTime and then change the format to Y-m-d
|
||||
$purchase_date = DateTime::createFromFormat('m/d/y', $date_purchase);
|
||||
|
||||
// need to manually create the created date
|
||||
$date_create = date('Y-m-d H:i:s');
|
||||
|
||||
// compute expiration date
|
||||
// TODO: might need checking for what kind of warranty for the warranty period
|
||||
// by default, we use private
|
||||
$warranty_class = WarrantyClass::WTY_PRIVATE;
|
||||
$date_expire = $this->computeDateExpire($purchase_date, $warr_private);
|
||||
|
||||
// convert all dates to string for the values string for the insert statement
|
||||
//$str_date_create = $date_create->format('Y-m-d H:i:s');
|
||||
$str_date_purchase = $purchase_date->format('Y-m-d H:i:s');
|
||||
$str_date_expire = $date_expire->format('Y-m-d H:i:s');
|
||||
|
||||
$first_name = addslashes($fname);
|
||||
$last_name = addslashes($lname);
|
||||
$mobile_number = addslashes($mobile);
|
||||
|
||||
// populate the values string for the values to be inserted into warranty
|
||||
$value_string = '(' . $model_id . ',' . $size_id . ',\'' . $sap_code . '\',\'' . $serial . '\',\'' . $warranty_class . '\',\''
|
||||
. $plate_number . '\',\'' . WarrantyStatus::ACTIVE . '\',\'' . $date_create . '\',\'' . $str_date_purchase
|
||||
. '\',\'' . $str_date_expire . '\',\'' . $first_name . '\',\'' . $last_name . '\',\'' . $mobile_number . '\',' . 1 . ',' . $vehicle_id . ',' . $cust_id . ',\'' . WarrantySource::BULK_UPLOAD . '\')';
|
||||
|
||||
if (strlen($sql_values) == 0)
|
||||
{
|
||||
// first entry to insert, should have no comma before
|
||||
$sql_values = $value_string;
|
||||
}
|
||||
else
|
||||
{
|
||||
// need to insert a comma after the existing string
|
||||
$sql_values = $sql_values . ',' . $value_string;
|
||||
}
|
||||
|
||||
// error_log($sql_values);
|
||||
|
||||
return $output_info;
|
||||
}
|
||||
|
||||
protected function validateFields($fields)
|
||||
{
|
||||
$errors = [];
|
||||
|
||||
$serial = trim($fields[self::F_SERIAL]);
|
||||
$date_purchase = trim($fields[self::F_DATE_PURCHASE]);
|
||||
$sap_code = trim($fields[self::F_BATT_ID]);
|
||||
$plate_number = trim($fields[self::F_PLATE_NUMBER]);
|
||||
|
||||
// clean the plate number
|
||||
$clean_plate = $this->cleanPlateNumber($plate_number);
|
||||
|
||||
// validate the plate number
|
||||
// (1) plate number should not be empty
|
||||
if (empty($clean_plate))
|
||||
{
|
||||
$message = 'No plate number.';
|
||||
$errors = $this->setOutputInfo($fields, 'NOT ADDED', $message);
|
||||
return $errors;
|
||||
}
|
||||
// validate date purchase
|
||||
// (1) date purchase should not be empty
|
||||
// (2) date purchase should be of format: d-M-y
|
||||
if (empty($date_purchase))
|
||||
{
|
||||
$message = 'No date purchase.';
|
||||
$errors = $this->setOutputInfo($fields, 'NOT ADDED', $message);
|
||||
return $errors;
|
||||
}
|
||||
|
||||
$purchase_date = DateTime::createFromFormat('m/d/y', $date_purchase);
|
||||
if ($purchase_date === false)
|
||||
{
|
||||
$message = 'Invalid date format. Date format should be: m/d/y (example: 06/13/16)';
|
||||
$errors = $this->setOutputInfo($fields, 'NOT ADDED', $message);
|
||||
return $errors;
|
||||
}
|
||||
// validate serial
|
||||
// (1) should not be empty
|
||||
if (empty($serial))
|
||||
{
|
||||
$message = 'No battery serial number.';
|
||||
$errors = $this->setOutputInfo($fields, 'NOT ADDED', $message);
|
||||
return $errors;
|
||||
}
|
||||
// validate battery
|
||||
// (1) should not be empty
|
||||
// (2) should find battery using sap_code.
|
||||
if (empty($sap_code))
|
||||
{
|
||||
$message = 'No battery ID.';
|
||||
$errors = $this->setOutputInfo($fields, 'NOT ADDED', $message);
|
||||
return $errors;
|
||||
}
|
||||
|
||||
if (!(isset($this->batt_hash[$sap_code])))
|
||||
{
|
||||
$message = 'Battery not found.';
|
||||
$errors = $this->setOutputInfo($fields, 'NOT ADDED', $message);
|
||||
return $errors;
|
||||
}
|
||||
|
||||
// (1) check if warranty exists using serial + plate number
|
||||
// (2) check if serial already exists even if for another plate number
|
||||
$conn = $this->em->getConnection();
|
||||
|
||||
// find warranties using serial + plate number
|
||||
$sql = 'SELECT w.id FROM warranty w WHERE w.serial = :serial AND w.plate_number = :plate_number';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute([
|
||||
'serial' => $serial,
|
||||
'plate_number' => $plate_number,
|
||||
]);
|
||||
|
||||
$warr_results = $stmt->fetchAll();
|
||||
|
||||
if (!empty($warr_results))
|
||||
{
|
||||
$message = 'Warranty already exists for serial and plate number.';
|
||||
$errors = $this->setOutputInfo($fields, 'NOT ADDED', $message);
|
||||
return $errors;
|
||||
}
|
||||
|
||||
// find warranties using serial number alone
|
||||
$w_sql = 'SELECT w.id FROM warranty w WHERE w.serial = :serial';
|
||||
$w_stmt = $conn->prepare($w_sql);
|
||||
$w_stmt->execute([
|
||||
'serial' => $serial,
|
||||
]);
|
||||
|
||||
$w_results = $w_stmt->fetchAll();
|
||||
|
||||
if (!empty($w_results))
|
||||
{
|
||||
$message = 'Warranty already exists for serial.';
|
||||
$errors = $this->setOutputInfo($fields, 'NOT ADDED', $message);
|
||||
return $errors;
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
protected function computeDateExpire($date_create, $warranty_period)
|
||||
{
|
||||
$expire_date = clone $date_create;
|
||||
$expire_date->add(new DateInterval('P'.$warranty_period.'M'));
|
||||
return $expire_date;
|
||||
}
|
||||
|
||||
protected function setOutputInfo($fields, $status, $message)
|
||||
{
|
||||
$encoder = trim($fields[self::F_ENCODER]);
|
||||
$date_encoded = trim($fields[self::F_DATE_ENCODED]);
|
||||
$fname = trim($fields[self::F_FNAME]);
|
||||
$lname = trim($fields[self::F_LNAME]);
|
||||
$email = trim($fields[self::F_EMAIL]);
|
||||
$address = trim($fields[self::F_ADDRESS]);
|
||||
$mobile = trim($fields[self::F_MOBILE]);
|
||||
$telephone = trim($fields[self::F_TELEPHONE]);
|
||||
$vmake = trim($fields[self::F_VMAKE]);
|
||||
$vmodel = trim($fields[self::F_VMODEL]);
|
||||
$year = trim($fields[self::F_MYEAR]);
|
||||
$serial = trim($fields[self::F_SERIAL]);
|
||||
$invoice_number = trim($fields[self::F_INVOICE_NUM]);
|
||||
$date_purchase = trim($fields[self::F_DATE_PURCHASE]);
|
||||
$dist_name = trim($fields[self::F_DIST_NAME]);
|
||||
$dist_address = trim($fields[self::F_DIST_ADDRESS]);
|
||||
$app_type_id = trim($fields[self::F_APP_TYPE_ID]);
|
||||
$sap_code = trim($fields[self::F_BATT_ID]);
|
||||
$plate_number = trim($fields[self::F_PLATE_NUMBER]);
|
||||
$owner_type = trim($fields[self::F_OWNER_TYPE]);
|
||||
|
||||
return [
|
||||
$encoder,
|
||||
$date_encoded,
|
||||
$fname,
|
||||
$lname,
|
||||
$email,
|
||||
$address,
|
||||
$mobile,
|
||||
$telephone,
|
||||
$vmake,
|
||||
$vmodel,
|
||||
$year,
|
||||
$plate_number,
|
||||
$serial,
|
||||
$invoice_number,
|
||||
$date_purchase,
|
||||
$dist_name,
|
||||
$dist_address,
|
||||
$app_type_id,
|
||||
$sap_code,
|
||||
$owner_type,
|
||||
$status,
|
||||
$message,
|
||||
];
|
||||
}
|
||||
|
||||
protected function outputWarrantyInfo($output_file, $entries)
|
||||
{
|
||||
try
|
||||
{
|
||||
$fh = fopen($output_file, "w");
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception('The file "' . $report_file . '" could be opened.');
|
||||
}
|
||||
|
||||
// write the headers
|
||||
fputcsv($fh, [
|
||||
'Encoded By',
|
||||
'Date of Encoded',
|
||||
'Owner First Name',
|
||||
'Owner Last Name',
|
||||
'Owner Email',
|
||||
'Owner Address',
|
||||
'Owner Mobile',
|
||||
'Owner Telephone',
|
||||
'Vehicle Make',
|
||||
'Vehicle Model',
|
||||
'Vehicle Year',
|
||||
'Vehicle Plate No.',
|
||||
'Battery Serial No.',
|
||||
'Battery Sales Invoice No.',
|
||||
'Battery Date of Purchase',
|
||||
'Distributor Name',
|
||||
'Distributor Address',
|
||||
'Application Type ID',
|
||||
'Battery ID',
|
||||
'Ownership Type',
|
||||
'Status',
|
||||
'Reason',
|
||||
]);
|
||||
|
||||
foreach($entries as $row)
|
||||
{
|
||||
if ($row != null)
|
||||
fputcsv($fh, $row);
|
||||
}
|
||||
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
|
||||
protected function populateBatteryIndex()
|
||||
{
|
||||
$conn = $this->em->getConnection();
|
||||
|
||||
// get all the batteries
|
||||
$sql = 'SELECT b.id, b.model_id, b.size_id, b.sap_code, b.warr_private, b.warr_commercial, b.warr_tnv
|
||||
FROM battery b';
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->execute();
|
||||
|
||||
$results = $stmt->fetchAll();
|
||||
|
||||
// go through the rows
|
||||
foreach ($results as $row)
|
||||
{
|
||||
// breaking this down for clarity
|
||||
$battery_id = $row['id'];
|
||||
$model_id = $row['model_id'];
|
||||
$size_id = $row['size_id'];
|
||||
$sap_code = trim($row['sap_code']);
|
||||
$warr_private = $row['warr_private'];
|
||||
$warr_commercial = $row['warr_commercial'];
|
||||
$warr_tnv = $row['warr_tnv'];
|
||||
|
||||
if(!empty($sap_code))
|
||||
{
|
||||
$this->batt_hash[$sap_code] = [
|
||||
'id' => $battery_id,
|
||||
'model_id' => $model_id,
|
||||
'size_id' => $size_id,
|
||||
'warr_private' => $warr_private,
|
||||
'warr_commercial' => $warr_commercial,
|
||||
'warr_tnv' => $warr_tnv,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function cleanPlateNumber($plate)
|
||||
{
|
||||
return strtoupper(str_replace(' ', '', $plate));
|
||||
}
|
||||
|
||||
}
|
||||
153
src/Command/UpdateUnacceptedJobOrdersCommand.php
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Service\MQTTClient;
|
||||
use App\Service\MQTTClientApiv2;
|
||||
use App\Service\FCMSender;
|
||||
|
||||
use App\Entity\JobOrder;
|
||||
use App\Entity\Rider;
|
||||
|
||||
use PDO;
|
||||
|
||||
class UpdateUnacceptedJobOrdersCommand extends Command
|
||||
{
|
||||
protected $em;
|
||||
protected $mclient;
|
||||
|
||||
// NOTE: for resq2 app
|
||||
protected $mclientv2;
|
||||
protected $fcmclient;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, MQTTClient $mclient, MQTTClientApiv2 $mclientv2, FCMSender $fcmclient)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->mclient = $mclient;
|
||||
|
||||
// NOTE: for resq2 app
|
||||
$this->mclientv2 = $mclientv2;
|
||||
$this->fcmclient = $fcmclient;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('joborder:reassignunaccepted')
|
||||
->setDescription('Requeue for rider assignment assigned but unaccepted job orders that have been assigned for more than 3 mins.')
|
||||
->setHelp('Requeue for rider assignment assigned but unaccepted job orders that have been assigned for more than 3 mins.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$em = $this->em;
|
||||
$mclient = $this->mclient;
|
||||
|
||||
// NOTE: for resq2 app
|
||||
$mclientv2 = $this->mclientv2;
|
||||
$fcmclient = $this->fcmclient;
|
||||
|
||||
// TODO: get the timeout limit from .env
|
||||
$timeout = 3;
|
||||
$current_status = 'assigned';
|
||||
$new_status = 'rider_assign';
|
||||
|
||||
// pdo connection
|
||||
$db = $em->getConnection();
|
||||
|
||||
// since we need the actual job orders for mqtt events, we need to get the ids of the job orders
|
||||
// that will be updated
|
||||
// need rider id to set rider to available since rider becomes unavailable
|
||||
// the minute JO is assigned to rider
|
||||
$query_sql = 'SELECT id FROM job_order WHERE status = :current_status and TIMESTAMPDIFF(MINUTE, date_assign, NOW()) >= :timeout';
|
||||
|
||||
$query_stmt = $db->prepare($query_sql);
|
||||
$query_stmt->execute([
|
||||
'current_status' => $current_status,
|
||||
'timeout' => $timeout,
|
||||
]);
|
||||
|
||||
// go through rows
|
||||
$requeued_jos = [];
|
||||
while ($row = $query_stmt->fetch(PDO::FETCH_NUM))
|
||||
{
|
||||
// $row[0] is the jo id
|
||||
// store the jos for now for the event sending after update of JOs
|
||||
// and the updating of rider's availability
|
||||
$jo_id = $row[0];
|
||||
|
||||
$requeued_jo = $em->getRepository(JobOrder::class)->find($jo_id);
|
||||
|
||||
$requeued_jos[] = [
|
||||
'jo' => $requeued_jo,
|
||||
];
|
||||
|
||||
$update_sql = 'UPDATE job_order SET status = :new_status, rider_id = null WHERE id = :jo_id';
|
||||
$update_stmt = $db->prepare($update_sql);
|
||||
$update_stmt->execute([
|
||||
'new_status' => $new_status,
|
||||
'jo_id' => $jo_id,
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($requeued_jos as $jo_info)
|
||||
{
|
||||
$jo = $jo_info['jo'];
|
||||
if ($jo != null)
|
||||
{
|
||||
// $output->writeln('Requeuing for rider assignment ' . $jo->getID());
|
||||
$id = $jo->getID();
|
||||
|
||||
// send notifications to rider app, telling rider that jo has been requeued
|
||||
$rider_payload = [
|
||||
'event' => 'cancelled',
|
||||
'reason' => 'Reassigned',
|
||||
'jo_id' => $id,
|
||||
];
|
||||
$mclient->sendRiderEvent($jo, $rider_payload);
|
||||
|
||||
|
||||
// send outlet assign since order should go back to hub and await reassignment to another rider
|
||||
$payload = [
|
||||
'event' => 'outlet_assign',
|
||||
'jo_id' => $id,
|
||||
];
|
||||
$mclient->sendEvent($jo, $payload);
|
||||
|
||||
// NOTE: for resq2 app
|
||||
$mclientv2->sendEvent($jo, $payload);
|
||||
$fcmclient->sendJoEvent($jo, "jo_fcm_title_outlet_assign", "jo_fcm_body_outlet_assign");
|
||||
}
|
||||
|
||||
$rider = $jo->getRider();
|
||||
if ($rider != null)
|
||||
{
|
||||
// check rider's current job order before changing rider's availability
|
||||
// since rider's current job order is set when JO is assigned to rider
|
||||
if ($rider->getCurrentJobOrder() != null)
|
||||
{
|
||||
if ($rider->getCurrentJobOrder()->getID() == $jo->getID())
|
||||
{
|
||||
// reset rider's availability to true
|
||||
$rider->setAvailable(true);
|
||||
|
||||
// set rider's current job order to null
|
||||
$rider->setCurrentJobOrder();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
184
src/Command/UpdateWarrantyDealerInfoCommand.php
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Entity\Warranty;
|
||||
|
||||
class UpdateWarrantyDealerInfoCommand extends Command
|
||||
{
|
||||
// field index in csv file
|
||||
const F_ID = 0;
|
||||
const F_BTY_MODEL_ID = 1;
|
||||
const F_BTY_SIZE_ID = 2;
|
||||
const F_SERIAL = 3;
|
||||
const F_WARRANTY_CLASS = 4;
|
||||
const F_PLATE_NUMBER = 5;
|
||||
const F_STATUS = 6;
|
||||
const F_DATE_CREATED = 7;
|
||||
const F_DATE_PURCHASE = 8;
|
||||
const F_DATE_EXPIRE = 9;
|
||||
const F_DATE_CLAIM = 10;
|
||||
const F_SAP_BTY_ID = 11;
|
||||
const F_CLAIM_ID = 12;
|
||||
const F_FIRST_NAME = 13;
|
||||
const F_LAST_NAME = 14;
|
||||
const F_MOBILE_NUMBER = 15;
|
||||
const F_ACTIVATED = 16;
|
||||
const F_WARR_PRIV_POLICY = 17;
|
||||
const F_EMAIL = 18;
|
||||
const F_VEHICLE_ID = 19;
|
||||
const F_CUSTOMER_ID = 20;
|
||||
const F_FILE_INVOICE = 21;
|
||||
const F_FILE_WARR_CARD = 22;
|
||||
const F_V_MODEL_YEAR = 23;
|
||||
const F_ODOMETER = 24;
|
||||
const F_DEALER_NAME = 25;
|
||||
const F_DEALER_ADDRESS = 26;
|
||||
const F_CONTACT_NUM = 27;
|
||||
const F_CUST_ADDRESS = 28;
|
||||
const F_DATE_PURCHASE_CUST = 29;
|
||||
const F_VALIDATED = 30;
|
||||
const F_PROVINCE_ID = 31;
|
||||
const F_MUNICIPALITY_ID = 32;
|
||||
const F_CREATE_SOURCE = 33;
|
||||
const F_DEALER_BRANCH_CODE = 34;
|
||||
|
||||
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('warranty:updatedealerinfo')
|
||||
->setDescription('Update warranty dealer information.')
|
||||
->setHelp('Update warranty dealer information.')
|
||||
->addArgument('input_file', InputArgument::REQUIRED, 'Path to the CSV file with the warranty info.')
|
||||
->addArgument('output_file', InputArgument::REQUIRED, 'Output filename');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
// for now, hardcode new dealer info (G-SIX SUMULONG)
|
||||
$new_dealer = [
|
||||
'name' => 'G-SIX SUMULONG',
|
||||
'address' => '175 SUMULONG HIGHWAY MAYAMOT RIZAL_X000D_',
|
||||
'branch_code' => 'ZN03587644',
|
||||
];
|
||||
|
||||
$csv_file = $input->getArgument('input_file');
|
||||
$output_file = $input->getArgument('output_file');
|
||||
|
||||
// attempt to open file
|
||||
try
|
||||
{
|
||||
$fh = fopen($csv_file, "r");
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception('The file "' . $csv_file . '" could be opened.');
|
||||
}
|
||||
|
||||
// start at 1 since 0 has the headers
|
||||
$row_num = 1;
|
||||
$output_info = [];
|
||||
while (($fields = fgetcsv($fh)) !== false)
|
||||
{
|
||||
// ignore first row
|
||||
if ($row_num == 1)
|
||||
{
|
||||
$row_num++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// process row
|
||||
$output_info[] = $this->processRow($fields, $new_dealer);
|
||||
|
||||
$row_num++;
|
||||
}
|
||||
|
||||
// write to output file
|
||||
$this->outputWarrantyInfo($output_file, $output_info);
|
||||
|
||||
fclose($fh);
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function processRow($fields, $new_dealer)
|
||||
{
|
||||
// get the warranty id
|
||||
$warranty_id = trim($fields[SELF::F_ID]);
|
||||
|
||||
// find the warranty
|
||||
$warranty = $this->em->getRepository(Warranty::class)->find($warranty_id);
|
||||
|
||||
if ($warranty == null)
|
||||
{
|
||||
// log warranty not found
|
||||
return $this->setOutputInfo($fields, 'NOT UPDATED', 'Warranty not found');
|
||||
}
|
||||
|
||||
// update warranty dealer information
|
||||
$dealer_name = $new_dealer['name'];
|
||||
$dealer_address = $new_dealer['address'];
|
||||
$dealer_branch_code = $new_dealer['branch_code'];
|
||||
|
||||
$warranty->setDealerName($dealer_name)
|
||||
->setDealerAddress($dealer_address)
|
||||
->setDealerBranchCode($dealer_branch_code);
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
// log successful update
|
||||
return $this->setOutputInfo($fields, 'UPDATED', '');
|
||||
}
|
||||
|
||||
protected function setOutputInfo($fields, $status, $reason)
|
||||
{
|
||||
$warranty_id = trim($fields[SELF::F_ID]);
|
||||
|
||||
return [
|
||||
$warranty_id,
|
||||
$status,
|
||||
$reason,
|
||||
];
|
||||
}
|
||||
|
||||
protected function outputWarrantyInfo($output_file, $entries)
|
||||
{
|
||||
try
|
||||
{
|
||||
$fh = fopen($output_file, "w");
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
throw new Exception('The file "' . $report_file . '" could be opened.');
|
||||
}
|
||||
|
||||
// write the headers
|
||||
fputcsv($fh, [
|
||||
'Warranty ID',
|
||||
'Status',
|
||||
'Reason',
|
||||
]);
|
||||
|
||||
foreach ($entries as $row)
|
||||
{
|
||||
fputcsv($fh, $row);
|
||||
}
|
||||
|
||||
fclose($fh);
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,8 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use App\Service\RisingTideGateway;
|
||||
|
|
@ -18,19 +20,21 @@ class WarrantySMSCommand extends Command
|
|||
{
|
||||
protected $gateway;
|
||||
protected $em;
|
||||
protected $translator;
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('warranty:sms')
|
||||
->setDescription('Sends an SMS message to users whose warranty expired one month ago.')
|
||||
->setDescription('Sends an SMS message to users whose warranty expired 45 days ago.')
|
||||
->setHelp('Sends warranty SMS.')
|
||||
->addArgument('date', InputArgument::OPTIONAL, 'Date to use as basis of expiration. Defaults to current date.');
|
||||
}
|
||||
|
||||
public function __construct(EntityManagerInterface $em, RisingTideGateway $gateway)
|
||||
public function __construct(EntityManagerInterface $em, RisingTideGateway $gateway, TranslatorInterface $translator)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->gateway = $gateway;
|
||||
$this->translator = $translator;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
|
@ -46,7 +50,7 @@ class WarrantySMSCommand extends Command
|
|||
$date = new DateTime();
|
||||
|
||||
// -1 month
|
||||
$date->modify('-1 month');
|
||||
$date->modify('-45 day');
|
||||
|
||||
$warrs = $this->em->getRepository(Warranty::class)->findBy(['date_expire' => $date]);
|
||||
|
||||
|
|
@ -97,10 +101,10 @@ class WarrantySMSCommand extends Command
|
|||
error_log(print_r($valid_numbers, true));
|
||||
foreach ($valid_numbers as $wdata)
|
||||
{
|
||||
$msg = 'Hi ' . $wdata['name'] . ', the warranty for the ' . $wdata['batt'] . ' installed in your car(' . $wdata['plate'] . ') has expired already. Please call MOTOLITE EXPRESS HATID at 8370-6686 to have the status of your battery checked to avoid any inconvenience. Thank you for choosing Motolite.';
|
||||
$msg = 'Hi ' . $wdata['name'] . ', the warranty for the ' . $wdata['batt'] . ' installed in your car(' . $wdata['plate'] . $this->translator->trans('message.partial_warrantysms');
|
||||
error_log($wdata['number'] . ' - sending ' . $msg);
|
||||
|
||||
$this->gateway->sendSMS($wdata['number'], 'MOTOLITE', $msg);
|
||||
$this->gateway->sendSMS($wdata['number'], $this->translator->trans('message.battery_brand_allcaps'), $msg);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use Catalyst\APIBundle\Entity\Role as APIRole;
|
||||
use Catalyst\APIBundle\Access\Generator as APIACLGenerator;
|
||||
use Catalyst\ApiBundle\Entity\Role as APIRole;
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
|
@ -19,7 +19,7 @@ class APIRoleController extends Controller
|
|||
{
|
||||
protected $api_acl_gen;
|
||||
|
||||
public function __construct(APIACLGenerator $api_acl_gen)
|
||||
public function __construct(ACLGenerator $api_acl_gen)
|
||||
{
|
||||
$this->api_acl_gen = $api_acl_gen;
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ class APIRoleController extends Controller
|
|||
protected function padAPIACLHierarchy(&$params)
|
||||
{
|
||||
// get acl keys hierarchy
|
||||
$api_acl_data = $this->api_acl_gen->getACL();
|
||||
$api_acl_data = $this->api_acl_gen->getACL('api');
|
||||
$params['api_acl_hierarchy'] = $api_acl_data['hierarchy'];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use Catalyst\APIBundle\Entity\User as APIUser;
|
||||
use Catalyst\APIBundle\Entity\Role as APIRole;
|
||||
use App\Entity\ApiUser as APIUser;
|
||||
use Catalyst\ApiBundle\Entity\Role as APIRole;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
@ -155,18 +155,20 @@ class APIUserController extends Controller
|
|||
// metadata
|
||||
$rider_id = $req->request->get('rider_id');
|
||||
$rider = $em->getRepository(Rider::class)->find($rider_id);
|
||||
// TODO: check for null rider
|
||||
if ($rider != null)
|
||||
{
|
||||
$meta = ['rider_id' => $rider_id];
|
||||
|
||||
$meta = ['rider_id' => $rider_id];
|
||||
// set api user in rider
|
||||
$rider->setAPIUser($obj);
|
||||
|
||||
// set api user in rider
|
||||
$rider->setAPIUser($obj);
|
||||
$obj->setRider($rider)
|
||||
->setMetadata($meta);
|
||||
}
|
||||
|
||||
// set and save values
|
||||
$obj->setName($req->request->get('name'))
|
||||
->setEnabled($req->request->get('enabled') ? true : false)
|
||||
->setMetadata($meta)
|
||||
->setRider($rider)
|
||||
->clearRoles();
|
||||
|
||||
// set roles
|
||||
|
|
|
|||
|
|
@ -271,20 +271,20 @@ class AnalyticsController extends Controller
|
|||
// add shift
|
||||
$args[] = $shift;
|
||||
|
||||
//error_log(print_r($args, true));
|
||||
// error_log(print_r($args, true));
|
||||
|
||||
error_log('running...' . $sched_script);
|
||||
// error_log('running...' . $sched_script);
|
||||
|
||||
$proc = new Process($args);
|
||||
$proc->run();
|
||||
|
||||
//error_log('getErrorOutput() ' . $proc->getErrorOutput());
|
||||
error_log('getErrorOutput() ' . $proc->getErrorOutput());
|
||||
|
||||
if (!$proc->isSuccessful())
|
||||
error_log('SCHEDULER DID NOT RUN PROPERLY');
|
||||
|
||||
$res = $proc->getOutput();
|
||||
error_log($res);
|
||||
// error_log($res);
|
||||
// returns lines with format: <day shift>-<hour shift>-<number of riders>
|
||||
|
||||
|
||||
|
|
@ -502,7 +502,7 @@ class AnalyticsController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
error_log('BEST - ' . $best_batt_id . ' - ' . $best_batt_count);
|
||||
// error_log('BEST - ' . $best_batt_id . ' - ' . $best_batt_count);
|
||||
|
||||
return $best_batt_id;
|
||||
}
|
||||
|
|
@ -798,6 +798,45 @@ class AnalyticsController extends Controller
|
|||
];
|
||||
}
|
||||
|
||||
if ($shift == '6AM_7PM') {
|
||||
$hour_shift = [
|
||||
['06:00 - 15:00', 6, 7, 8, 9, 10, 11, 12, 13, 14],
|
||||
['07:00 - 16:00', 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||
['08:00 - 17:00', 8, 9, 10, 11, 12, 13, 14, 15, 16],
|
||||
['09:00 - 18:00', 9, 10, 11, 12, 13, 14, 15, 16, 17],
|
||||
['10:00 - 19:00', 10, 11, 12, 13, 14, 15, 16, 17, 18]
|
||||
];
|
||||
}
|
||||
|
||||
if ($shift == '6AM_10PM') {
|
||||
$hour_shift = [
|
||||
['06:00 - 15:00', 6, 7, 8, 9, 10, 11, 12, 13, 14],
|
||||
['07:00 - 16:00', 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||
['08:00 - 17:00', 8, 9, 10, 11, 12, 13, 14, 15, 16],
|
||||
['09:00 - 18:00', 9, 10, 11, 12, 13, 14, 15, 16, 17],
|
||||
['10:00 - 19:00', 10, 11, 12, 13, 14, 15, 16, 17, 18],
|
||||
['11:00 - 20:00', 11, 12, 13, 14, 15, 16, 17, 18, 19],
|
||||
['12:00 - 21:00', 12, 13, 14, 15, 16, 17, 18, 19, 20],
|
||||
['13:00 - 22:00', 13, 14, 15, 16, 17, 18, 19, 20, 21]
|
||||
];
|
||||
}
|
||||
|
||||
if ($shift == '6AM-12AM') {
|
||||
$hour_shift = [
|
||||
['06:00 - 15:00', 6, 7, 8, 9, 10, 11, 12, 13, 14],
|
||||
['07:00 - 16:00', 7, 8, 9, 10, 11, 12, 13, 14, 15],
|
||||
['08:00 - 17:00', 8, 9, 10, 11, 12, 13, 14, 15, 16],
|
||||
['09:00 - 18:00', 9, 10, 11, 12, 13, 14, 15, 16, 17],
|
||||
['10:00 - 19:00', 10, 11, 12, 13, 14, 15, 16, 17, 18],
|
||||
['11:00 - 20:00', 11, 12, 13, 14, 15, 16, 17, 18, 19],
|
||||
['12:00 - 21:00', 12, 13, 14, 15, 16, 17, 18, 19, 20],
|
||||
['13:00 - 22:00', 13, 14, 15, 16, 17, 18, 19, 20, 21],
|
||||
['14:00 - 23:00', 14, 15, 16, 17, 18, 19, 20, 21, 22],
|
||||
['15:00 - 00:00', 15, 16, 17, 18, 19, 20, 21, 22, 23],
|
||||
['16:00 - 01:00', 16, 17, 18, 19, 20, 21, 22, 23, 0]
|
||||
];
|
||||
}
|
||||
|
||||
return $hour_shift;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ class BatteryController extends Controller
|
|||
$row['height'] = $orow[0]->getHeight();
|
||||
$row['total_height'] = $orow[0]->getTotalHeight();
|
||||
$row['image_file'] = $orow[0]->getImageFile();
|
||||
$row['flag_active'] = $orow[0]->isActive();
|
||||
|
||||
// add row metadata
|
||||
$row['meta'] = [
|
||||
|
|
@ -182,7 +183,8 @@ class BatteryController extends Controller
|
|||
->setHeight($req->request->get('height'))
|
||||
->setTotalHeight($req->request->get('total_height'))
|
||||
->setSellingPrice($req->request->get('sell_price'))
|
||||
->setImageFile($req->request->get('image_file'));
|
||||
->setImageFile($req->request->get('image_file'))
|
||||
->setActive($req->request->get('flag_active', false));
|
||||
|
||||
// initialize error list
|
||||
$error_array = [];
|
||||
|
|
@ -308,6 +310,7 @@ class BatteryController extends Controller
|
|||
->setTotalHeight($req->request->get('total_height'))
|
||||
->setSellingPrice($req->request->get('sell_price'))
|
||||
->setImageFile($req->request->get('image_file'))
|
||||
->setActive($req->request->get('flag_active', false))
|
||||
->clearVehicles();
|
||||
|
||||
// initialize error list
|
||||
|
|
@ -424,7 +427,7 @@ class BatteryController extends Controller
|
|||
$bmodel_id = $req->query->get('model_id');
|
||||
$bsize_id = $req->query->get('size_id');
|
||||
|
||||
// find the battery using model and size
|
||||
// find the battery using model and size and battery must be active
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$query = $em->createQuery('SELECT b FROM App\Entity\Battery b
|
||||
JOIN b.model bm
|
||||
|
|
@ -432,7 +435,8 @@ class BatteryController extends Controller
|
|||
JOIN b.manufacturer bmfg
|
||||
WHERE bm.id = :bm_id
|
||||
AND bs.id = :bs_id
|
||||
AND bmfg.id = :bmfg_id')
|
||||
AND bmfg.id = :bmfg_id
|
||||
AND b.flag_active = true')
|
||||
->setParameter('bmfg_id', $bmfg_id)
|
||||
->setParameter('bm_id', $bmodel_id)
|
||||
->setParameter('bs_id', $bsize_id);
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ class BatteryManufacturerController extends Controller
|
|||
|
||||
// get row data
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$all_batts = $em->getRepository(Battery::class)->findAll();
|
||||
$all_batts = $em->getRepository(Battery::class)->findBy(['flag_active' => true]);
|
||||
|
||||
foreach ($all_batts as $battery)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
|
||||
use App\Entity\SAPBattery;
|
||||
use App\Entity\SAPBatterySize;
|
||||
use App\Entity\SAPBatteryBrand;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
class BatteryController extends APIController
|
||||
{
|
||||
|
|
@ -113,7 +113,7 @@ class BatteryController extends APIController
|
|||
];
|
||||
|
||||
$msg = $this->checkRequiredParameters($req, $params);
|
||||
error_log('msg - ' . $msg);
|
||||
// error_log('msg - ' . $msg);
|
||||
if ($msg)
|
||||
return new APIResponse(false, $msg);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,16 +8,18 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\CustomerVehicle;
|
||||
use App\Entity\Vehicle;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
use App\Service\HashGenerator;
|
||||
|
||||
class CustomerController extends APIController
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
class CustomerController extends ApiController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
|
|
@ -44,7 +46,7 @@ class CustomerController extends APIController
|
|||
];
|
||||
|
||||
$msg = $this->checkRequiredParameters($req, $params);
|
||||
error_log('msg - ' . $msg);
|
||||
// error_log('msg - ' . $msg);
|
||||
if ($msg)
|
||||
return new APIResponse(false, $msg);
|
||||
|
||||
|
|
@ -70,7 +72,7 @@ class CustomerController extends APIController
|
|||
{
|
||||
// remove first '0'
|
||||
$mobile_number = substr($mobile_number, 1);
|
||||
error_log("CONVERTED TO $mobile_number");
|
||||
// error_log("CONVERTED TO $mobile_number");
|
||||
}
|
||||
|
||||
// does it fit our 9XXXXXXXXX pattern?
|
||||
|
|
@ -202,6 +204,45 @@ class CustomerController extends APIController
|
|||
return new APIResponse(true, $message, $data);
|
||||
}
|
||||
|
||||
public function verifyCustomer($customer_hash, EntityManagerInterface $em, HashGenerator $hash)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('customer.verify', null, 'No access.');
|
||||
|
||||
// get customer id from customer_hash
|
||||
$cust_id = $hash->getID($customer_hash);
|
||||
|
||||
if ($cust_id == null)
|
||||
return new APIResponse(false, 'Invalid customer hash.');
|
||||
|
||||
// find customer using id
|
||||
$customer = $em->getRepository(Customer::class)->find($cust_id);
|
||||
|
||||
$data = [];
|
||||
$message = '';
|
||||
if ($customer == null)
|
||||
{
|
||||
$message = 'Customer not found.';
|
||||
$data[] = [
|
||||
'is_customer' => false,
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'mobile_number' => '',
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = 'Customer found.';
|
||||
$data[] = [
|
||||
'is_customer' => true,
|
||||
'first_name' => $customer->getFirstName(),
|
||||
'last_name' => $customer->getLastName(),
|
||||
'mobile_number' => $customer->getPhoneMobile(),
|
||||
];
|
||||
}
|
||||
|
||||
return new APIResponse(true, $message, $data);
|
||||
}
|
||||
|
||||
protected function cleanPlateNumber($plate)
|
||||
{
|
||||
// remove spaces and make upper case
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ use Doctrine\ORM\Query;
|
|||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
|
||||
use App\Service\RisingTideGateway;
|
||||
use App\Service\WarrantyAPILogger;
|
||||
|
|
@ -37,10 +37,10 @@ use App\Ramcar\WarrantySource;
|
|||
|
||||
use DateTime;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
// third party API
|
||||
class CustomerWarrantyController extends APIController
|
||||
class CustomerWarrantyController extends ApiController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
|
|
@ -89,18 +89,30 @@ class CustomerWarrantyController extends APIController
|
|||
return true;
|
||||
}
|
||||
|
||||
protected function cleanSerial($serial)
|
||||
{
|
||||
return trim(strtoupper($serial));
|
||||
}
|
||||
|
||||
protected function cleanPlateNumber($plate_num)
|
||||
{
|
||||
return preg_replace('/\s+/', '', strtoupper($plate_num));
|
||||
}
|
||||
|
||||
// TODO: put this in a service
|
||||
protected function cleanSerial($serial)
|
||||
{
|
||||
// trim and make everything upper case
|
||||
$clean_serial = trim(strtoupper($serial));
|
||||
|
||||
|
||||
// remove QR prefix if it exists
|
||||
//$prefix = substr($clean_serial, 0, 2);
|
||||
//if ($prefix == 'QR')
|
||||
// $clean_serial = substr($clean_serial, 2);
|
||||
|
||||
return $clean_serial;
|
||||
}
|
||||
|
||||
public function check($serial, EntityManagerInterface $em, Request $req, WarrantyAPILogger $logger)
|
||||
{
|
||||
$serial = $this->cleanSerial($serial);
|
||||
|
||||
$user_id = $_SERVER['HTTP_X_CATA_API_KEY'];
|
||||
$log_data = [
|
||||
'serial' => $serial,
|
||||
|
|
@ -115,7 +127,7 @@ class CustomerWarrantyController extends APIController
|
|||
if (!$res)
|
||||
return $res;
|
||||
|
||||
error_log('check warranty serial');
|
||||
// error_log('check warranty serial');
|
||||
|
||||
// TODO: add logging for the other scenarios
|
||||
// check if warranty serial is there
|
||||
|
|
@ -134,7 +146,7 @@ class CustomerWarrantyController extends APIController
|
|||
// if we have a warranty entry for the serial already
|
||||
if ($warr != null)
|
||||
{
|
||||
error_log('already have warranty.');
|
||||
// error_log('already have warranty.');
|
||||
|
||||
$warr_plate = $warr->getPlateNumber();
|
||||
$is_registered = true;
|
||||
|
|
@ -303,7 +315,8 @@ class CustomerWarrantyController extends APIController
|
|||
public function register($serial, EntityManagerInterface $em, Request $req, KernelInterface $kernel, RisingTideGateway $rt, TranslatorInterface $trans,
|
||||
WarrantyAPILogger $logger)
|
||||
{
|
||||
error_log('HERE - register');
|
||||
$serial = $this->cleanSerial($serial);
|
||||
// error_log('HERE - register');
|
||||
|
||||
// set up information for logging
|
||||
// get user from header
|
||||
|
|
@ -325,7 +338,7 @@ class CustomerWarrantyController extends APIController
|
|||
$username = $this->getUser()->getName();
|
||||
$source = 'CAPI_USER_' . $username;
|
||||
|
||||
error_log('SOURCE: ' . $source);
|
||||
// error_log('SOURCE: ' . $source);
|
||||
|
||||
// TODO: maybe add vmake_id? since warranty cannot be created with no vmake
|
||||
// TODO: maybe also add mobile and email since customer creation won't let mobile and email be null
|
||||
|
|
@ -345,7 +358,7 @@ class CustomerWarrantyController extends APIController
|
|||
$invoice = $req->files->get('invoice');
|
||||
$warr_card = $req->files->get('warr_card');
|
||||
|
||||
error_log('handling file uploads');
|
||||
// error_log('handling file uploads');
|
||||
// process picture uploads
|
||||
$upload_dir = $kernel->getProjectDir() . '/public/warranty_uploads';
|
||||
$inv_filename = $this->handlePictureUpload($invoice, $upload_dir, $serial, 'invoice');
|
||||
|
|
@ -366,11 +379,13 @@ class CustomerWarrantyController extends APIController
|
|||
// TODO: move this to a service, since it's shared by all warranty updaters
|
||||
protected function handlePictureUpload($file, $target_dir, $serial, $name)
|
||||
{
|
||||
error_log("handling $name upload");
|
||||
$serial = $this->cleanSerial($serial);
|
||||
|
||||
// error_log("handling $name upload");
|
||||
// no file sent
|
||||
if ($file == null)
|
||||
{
|
||||
error_log('no file');
|
||||
error_log("handling $name upload but no file");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -388,8 +403,8 @@ class CustomerWarrantyController extends APIController
|
|||
$filename = $name . '.' . $file->getClientOriginalExtension();
|
||||
$file->move($target_dir . '/' . $serial, $filename);
|
||||
|
||||
error_log("filename - $filename");
|
||||
error_log($target_dir . '/' . $serial . '/' . $filename);
|
||||
// error_log("filename - $filename");
|
||||
// error_log($target_dir . '/' . $serial . '/' . $filename);
|
||||
|
||||
return $serial . '/' . $filename;
|
||||
}
|
||||
|
|
@ -399,7 +414,7 @@ class CustomerWarrantyController extends APIController
|
|||
{
|
||||
$plate_num = $this->cleanPlateNumber($req->request->get('plate_num'));
|
||||
|
||||
error_log('warranty serial check');
|
||||
// error_log('warranty serial check');
|
||||
// get serial
|
||||
$warr_serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
||||
if ($warr_serial == null)
|
||||
|
|
@ -438,7 +453,7 @@ class CustomerWarrantyController extends APIController
|
|||
$warr->setCreateSource($source);
|
||||
}
|
||||
|
||||
error_log('sap battery check');
|
||||
// error_log('sap battery check');
|
||||
// get sap battery
|
||||
$sku = $warr_serial->getSKU();
|
||||
$sap_bty = null;
|
||||
|
|
@ -467,7 +482,7 @@ class CustomerWarrantyController extends APIController
|
|||
}
|
||||
}
|
||||
|
||||
error_log('date check');
|
||||
// error_log('date check');
|
||||
// default date purchase to today
|
||||
// NOTE: might need to change this later
|
||||
$date_pur = new DateTime();
|
||||
|
|
@ -513,7 +528,7 @@ class CustomerWarrantyController extends APIController
|
|||
}
|
||||
|
||||
|
||||
error_log('update entity / database');
|
||||
// error_log('update entity / database');
|
||||
// create or update warranty entry
|
||||
$warr->setSerial($serial)
|
||||
->setFirstName($req->request->get('first_name'))
|
||||
|
|
@ -563,12 +578,12 @@ class CustomerWarrantyController extends APIController
|
|||
|
||||
|
||||
// send sms confirmation
|
||||
$this->sendSMSConfirmation($rt, $req->request->get('contact_num'), $sms_message);
|
||||
$this->sendSMSConfirmation($rt, $req->request->get('contact_num'), $sms_message, $trans);
|
||||
|
||||
return new APIResponse(true, 'Warranty registered.', $data);
|
||||
}
|
||||
|
||||
protected function sendSMSConfirmation($rt, $num, $message)
|
||||
protected function sendSMSConfirmation($rt, $num, $message, $trans)
|
||||
{
|
||||
$clean_num = trim($num);
|
||||
|
||||
|
|
@ -585,8 +600,8 @@ class CustomerWarrantyController extends APIController
|
|||
if ($clean_num[0] != '0' && $clean_num[0] != '6')
|
||||
return false;
|
||||
|
||||
error_log('sending sms to - ' . $clean_num);
|
||||
// error_log('sending sms to - ' . $clean_num);
|
||||
|
||||
$rt->sendSMS($clean_num, 'MOTOLITE', $message);
|
||||
$rt->sendSMS($clean_num, $trans->trans('message.battery_brand_allcaps'), $message);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
|
||||
use App\Entity\Dealer;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
class DealerController extends APIController
|
||||
class DealerController extends ApiController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
|
|
|
|||
53
src/Controller/CAPI/HubController.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CAPI;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
|
||||
use App\Entity\Hub;
|
||||
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
class HubController extends ApiController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
public function __construct(ACLGenerator $acl_gen)
|
||||
{
|
||||
$this->acl_gen = $acl_gen;
|
||||
}
|
||||
|
||||
public function getAll(EntityManagerInterface $em)
|
||||
{
|
||||
// get all hub data order by name
|
||||
$this->denyAccessUnlessGranted('hub.list', null, 'No access.');
|
||||
|
||||
$results = $em->getRepository(Hub::class)->findBy([], ['name' => 'ASC']);
|
||||
|
||||
$hubs = [];
|
||||
foreach($results as $res)
|
||||
{
|
||||
$hub_id = $res->getId();
|
||||
$hub_name = $res->getName();
|
||||
$hub_address = $res->getAddress();
|
||||
$hub_branch_code = $res->getBranchCode();
|
||||
|
||||
$hubs[$hub_id] = [
|
||||
'id' => $hub_id,
|
||||
'name' => $hub_name,
|
||||
'address' => $hub_address,
|
||||
'branch_code' => $hub_branch_code,
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'hubs' => $hubs,
|
||||
];
|
||||
return new APIResponse(true, 'Hubs loaded.', $data);
|
||||
}
|
||||
}
|
||||
139
src/Controller/CAPI/JobOrderController.php
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CAPI;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
|
||||
use App\Entity\JobOrder;
|
||||
use App\Entity\Warranty;
|
||||
|
||||
use App\Ramcar\JOStatus;
|
||||
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
class JobOrderController extends ApiController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
public function __construct(ACLGenerator $acl_gen)
|
||||
{
|
||||
$this->acl_gen = $acl_gen;
|
||||
}
|
||||
|
||||
public function getJobOrder($id, EntityManagerInterface $em)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('joborder.find', null, 'No access.');
|
||||
|
||||
$jo = $em->getRepository(JobOrder::class)->find($id);
|
||||
|
||||
if ($jo == null)
|
||||
return new APIResponse(false, 'No job order found with that number.', null, 404);
|
||||
|
||||
$data = $this->generateJobOrderData($jo, $em);
|
||||
|
||||
return new APIResponse(true, 'Job order found.', $data);
|
||||
}
|
||||
|
||||
protected function generateJobOrderData($jo, EntityManagerInterface $em)
|
||||
{
|
||||
// customer vehicle
|
||||
$cv = $jo->getCustomerVehicle();
|
||||
|
||||
// customer information
|
||||
$customer = $jo->getCustomer();
|
||||
|
||||
// hub
|
||||
$hub_name = '';
|
||||
$hub = $jo->getHub();
|
||||
if ($hub != null)
|
||||
$hub_name = $hub->getName();
|
||||
|
||||
// check if JO is fulfilled, if not, we leave date_purchase blank
|
||||
$date_purchase = '';
|
||||
$serial = '';
|
||||
$status = $jo->getStatus();
|
||||
if ($status == JOStatus::FULFILLED)
|
||||
{
|
||||
if ($jo->getDateFulfill() != null)
|
||||
$date_purchase = $jo->getDateFulfill()->format('M d, Y H:i');
|
||||
|
||||
// find warranty to get the serial using plate number
|
||||
$serial = $this->getSerialFromWarranty($cv->getPlateNumber(), $em);
|
||||
}
|
||||
|
||||
$jo_data = [
|
||||
'id' => $jo->getID(),
|
||||
'first_name' => $customer->getFirstName(),
|
||||
'last_name' => $customer->getLastName(),
|
||||
'mobile_number' => $customer->getPhoneMobile(),
|
||||
'email' => $customer->getEmail(),
|
||||
'plate_number' => $cv->getPlateNumber(),
|
||||
'date_purchase' => $date_purchase,
|
||||
'address' => $jo->getDeliveryAddress(),
|
||||
'hub' => $hub_name,
|
||||
'serial' => $serial,
|
||||
];
|
||||
|
||||
// invoice items
|
||||
$items = [];
|
||||
$jo_items = $jo->getInvoice()->getItems();
|
||||
$non_battery_item_titles = ['Promo discount', 'Trade-in', 'Service'];
|
||||
foreach ($jo_items as $item)
|
||||
{
|
||||
$item_title = $item->getTitle();
|
||||
|
||||
// check if title has Promo discount, Trade-in, or Service
|
||||
$flag_battery = $this->checkIfBatteryInvoiceItem($item_title, $non_battery_item_titles);
|
||||
if ($flag_battery == true)
|
||||
{
|
||||
$items[] = [
|
||||
'title' => $item->getTitle(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$jo_data['items'] = $items;
|
||||
|
||||
return $jo_data;
|
||||
}
|
||||
|
||||
protected function checkIfBatteryInvoiceItem($item_title, $non_battery_item_titles)
|
||||
{
|
||||
foreach ($non_battery_item_titles as $nb_item_title)
|
||||
{
|
||||
$pos_result = stripos($item_title, $nb_item_title);
|
||||
|
||||
// if found, invoice item is not a battery item
|
||||
if ($pos_result !== false)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getSerialFromWarranty($plate_number, EntityManagerInterface $em)
|
||||
{
|
||||
// NOTE: Modify the search for the latest warranty. This seems hacky.
|
||||
// get latest warranty using plate number
|
||||
$warranty_results = $em->getRepository(Warranty::class)->findBy(
|
||||
['plate_number' => $plate_number],
|
||||
['date_create' => 'desc']
|
||||
);
|
||||
|
||||
$serial = '';
|
||||
if (!empty($warranty_results))
|
||||
{
|
||||
// get first entry
|
||||
$warranty = current($warranty_results);
|
||||
|
||||
$serial = $warranty->getSerial();
|
||||
}
|
||||
|
||||
return $serial;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,14 +6,14 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
|
||||
use App\Entity\Municipality;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
class MunicipalityController extends APIController
|
||||
class MunicipalityController extends ApiController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
|
||||
use App\Entity\PrivacyPolicy;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
// third party API
|
||||
class PrivacyPolicyController extends APIController
|
||||
class PrivacyPolicyController extends ApiController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,13 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
||||
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
|
||||
use App\Entity\Rider;
|
||||
use App\Entity\JOEvent;
|
||||
|
|
@ -20,16 +22,21 @@ use App\Entity\BatteryModel;
|
|||
use App\Entity\BatterySize;
|
||||
use App\Entity\RiderAPISession;
|
||||
use App\Entity\User;
|
||||
use Catalyst\APIBundle\Entity\User as APIUser;
|
||||
|
||||
use App\Entity\ApiUser as APIUser;
|
||||
use App\Entity\JobOrder;
|
||||
use App\Entity\SAPBattery;
|
||||
use App\Entity\WarrantySerial;
|
||||
use App\Service\RedisClientProvider;
|
||||
use App\Service\RiderCache;
|
||||
use App\Service\MQTTClient;
|
||||
use App\Service\MQTTClientApiv2;
|
||||
use App\Service\FCMSender;
|
||||
use App\Service\WarrantyHandler;
|
||||
use App\Service\JobOrderHandlerInterface;
|
||||
use App\Service\InvoiceGeneratorInterface;
|
||||
use App\Service\RisingTideGateway;
|
||||
use App\Service\RiderTracker;
|
||||
use App\Service\PriceTierManager;
|
||||
|
||||
use App\Ramcar\ServiceType;
|
||||
use App\Ramcar\TradeInType;
|
||||
|
|
@ -44,7 +51,7 @@ use App\Ramcar\DeliveryStatus;
|
|||
use DateTime;
|
||||
|
||||
// third party API for rider
|
||||
class RiderAppController extends APIController
|
||||
class RiderAppController extends ApiController
|
||||
{
|
||||
/*
|
||||
public function register(Request $req, EntityManagerInterface $em, RedisClientProvider $redis)
|
||||
|
|
@ -282,8 +289,9 @@ class RiderAppController extends APIController
|
|||
|
||||
// do we have a job order?
|
||||
// $jo = $rider->getActiveJobOrder();
|
||||
// NOTE: we do not include job orders that have been cancelled
|
||||
$jo = $rider->getCurrentJobOrder();
|
||||
if ($jo == null)
|
||||
if ($jo == null || $jo->getStatus() == JOStatus::CANCELLED)
|
||||
{
|
||||
$data = [
|
||||
'job_order' => null
|
||||
|
|
@ -378,6 +386,7 @@ class RiderAppController extends APIController
|
|||
'flag_coolant' => $jo->hasCoolant(),
|
||||
'has_motolite' => $cv->hasMotoliteBattery(),
|
||||
'delivery_status' => $jo->getDeliveryStatus(),
|
||||
'flag_sealant' => $jo->hasSealant(),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
|
@ -404,6 +413,11 @@ class RiderAppController extends APIController
|
|||
if (!empty($msg))
|
||||
return new APIResponse(false, $msg);
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// TODO: refactor this into a jo handler class, so we don't have to repeat for control center
|
||||
|
||||
// set jo status to in transit
|
||||
|
|
@ -435,7 +449,7 @@ class RiderAppController extends APIController
|
|||
|
||||
}
|
||||
|
||||
public function cancelJobOrder(Request $req, EntityManagerInterface $em, MQTTClient $mclient)
|
||||
public function cancelJobOrder(Request $req, EntityManagerInterface $em, MQTTClient $mclient, MQTTClientApiv2 $mclientv2, FCMSender $fcmclient)
|
||||
{
|
||||
$required_params = ['jo_id'];
|
||||
|
||||
|
|
@ -451,7 +465,13 @@ class RiderAppController extends APIController
|
|||
|
||||
$msg = $this->checkJO($req, $required_params, $jo, $rider);
|
||||
if (!empty($msg))
|
||||
return new APIResponse(false, $msg);
|
||||
// TODO: this is a workaround for requeue, because rider app gets stuck in accept / decline screen
|
||||
return new APIResponse(true, $msg);
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// requeue it, instead of cancelling it
|
||||
$jo->requeue();
|
||||
|
|
@ -480,6 +500,10 @@ class RiderAppController extends APIController
|
|||
];
|
||||
$mclient->sendEvent($jo, $payload);
|
||||
|
||||
// NOTE: for resq2 app
|
||||
$mclientv2->sendEvent($jo, $payload);
|
||||
$fcmclient->sendJoEvent($jo, "jo_fcm_title_outlet_assign", "jo_fcm_body_outlet_assign");
|
||||
|
||||
$data = [];
|
||||
return new APIResponse(true, 'Job order requeued.', $data);
|
||||
}
|
||||
|
|
@ -507,6 +531,11 @@ class RiderAppController extends APIController
|
|||
// get rider's current job order
|
||||
$jo = $rider->getCurrentJobOrder();
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// set delivery status
|
||||
$jo->setDeliveryStatus(DeliveryStatus::RIDER_DEPART_HUB);
|
||||
|
||||
|
|
@ -547,6 +576,11 @@ class RiderAppController extends APIController
|
|||
// get rider's current job order
|
||||
$jo = $rider->getCurrentJobOrder();
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// set delivery status
|
||||
$jo->setDeliveryStatus(DeliveryStatus::RIDER_ARRIVE_HUB_PRE_JO);
|
||||
|
||||
|
|
@ -587,6 +621,11 @@ class RiderAppController extends APIController
|
|||
// get rider's current job order
|
||||
$jo = $rider->getCurrentJobOrder();
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// set delivery status
|
||||
$jo->setDeliveryStatus(DeliveryStatus::RIDER_DEPART_HUB_PRE_JO);
|
||||
|
||||
|
|
@ -627,6 +666,11 @@ class RiderAppController extends APIController
|
|||
// get rider's current job order
|
||||
$jo = $rider->getCurrentJobOrder();
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// set delivery status
|
||||
$jo->setDeliveryStatus(DeliveryStatus::RIDER_START);
|
||||
|
||||
|
|
@ -645,7 +689,7 @@ class RiderAppController extends APIController
|
|||
|
||||
}
|
||||
|
||||
public function arrive(Request $req, EntityManagerInterface $em, MQTTClient $mclient)
|
||||
public function arrive(Request $req, EntityManagerInterface $em, MQTTClient $mclient, MQTTClientApiv2 $mclientv2, FCMSender $fcmclient)
|
||||
{
|
||||
$required_params = ['jo_id'];
|
||||
|
||||
|
|
@ -668,6 +712,11 @@ class RiderAppController extends APIController
|
|||
// set jo status to in progress
|
||||
$jo->setStatus(JOStatus::IN_PROGRESS);
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// set delivery status
|
||||
$jo->setDeliveryStatus(DeliveryStatus::RIDER_ARRIVE);
|
||||
|
||||
|
|
@ -695,6 +744,10 @@ class RiderAppController extends APIController
|
|||
];
|
||||
$mclient->sendEvent($jo, $payload);
|
||||
|
||||
// NOTE: for resq2 app
|
||||
$mclientv2->sendEvent($jo, $payload);
|
||||
$fcmclient->sendJoEvent($jo, "jo_fcm_title_driver_arrived", "jo_fcm_body_driver_arrived");
|
||||
|
||||
$data = [];
|
||||
return new APIResponse(true, 'Rider arrived at customer location.', $data);
|
||||
}
|
||||
|
|
@ -722,6 +775,11 @@ class RiderAppController extends APIController
|
|||
// get rider's current job order
|
||||
$jo = $rider->getCurrentJobOrder();
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// set delivery status
|
||||
$jo->setDeliveryStatus(DeliveryStatus::RIDER_ARRIVE_HUB);
|
||||
|
||||
|
|
@ -745,8 +803,56 @@ class RiderAppController extends APIController
|
|||
return new APIResponse(true, 'Rider arrive at hub.', $data);
|
||||
}
|
||||
|
||||
public function getBatterySizes(Request $req, EntityManagerInterface $em)
|
||||
{
|
||||
// get capi user
|
||||
$capi_user = $this->getUser();
|
||||
if ($capi_user == null)
|
||||
return new APIResponse(false, 'User not found.');
|
||||
|
||||
// get rider id from capi user metadata
|
||||
$rider = $this->getRiderFromCAPI($capi_user, $em);
|
||||
if ($rider == null)
|
||||
return new APIResponse(false, 'No rider found.');
|
||||
|
||||
// get sizes
|
||||
$qb = $em->getRepository(BatterySize::class)
|
||||
->createQueryBuilder('bs');
|
||||
|
||||
$sizes = $qb->select('bs.id, bs.name')
|
||||
->orderBy('bs.name', 'asc')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
// response
|
||||
return new APIResponse(true, '', [
|
||||
'sizes' => $sizes,
|
||||
]);
|
||||
}
|
||||
|
||||
public function getTradeInTypes(Request $req, EntityManagerInterface $em)
|
||||
{
|
||||
// get capi user
|
||||
$capi_user = $this->getUser();
|
||||
if ($capi_user == null)
|
||||
return new APIResponse(false, 'User not found.');
|
||||
|
||||
// get rider id from capi user metadata
|
||||
$rider = $this->getRiderFromCAPI($capi_user, $em);
|
||||
if ($rider == null)
|
||||
return new APIResponse(false, 'No rider found.');
|
||||
|
||||
// get trade-in types
|
||||
$types = TradeInType::getCollection();
|
||||
|
||||
// response
|
||||
return new APIResponse(true, '', [
|
||||
'types' => $types,
|
||||
]);
|
||||
}
|
||||
|
||||
public function payment(Request $req, EntityManagerInterface $em, JobOrderHandlerInterface $jo_handler,
|
||||
RisingTideGateway $rt, WarrantyHandler $wh, MQTTClient $mclient)
|
||||
RisingTideGateway $rt, WarrantyHandler $wh, MQTTClient $mclient, MQTTClientApiv2 $mclientv2, FCMSender $fcmclient, TranslatorInterface $translator)
|
||||
{
|
||||
$required_params = ['jo_id'];
|
||||
|
||||
|
|
@ -764,6 +870,22 @@ class RiderAppController extends APIController
|
|||
if (!empty($msg))
|
||||
return new APIResponse(false, $msg);
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// need to check if service type is battery sales
|
||||
// if so, serial is a required parameter
|
||||
$serial = $req->request->get('serial', '');
|
||||
if ($jo->getServiceType() == ServiceType::BATTERY_REPLACEMENT_NEW)
|
||||
{
|
||||
/*
|
||||
if (empty($serial))
|
||||
return new APIResponse(false, 'Missing parameter(s): serial');
|
||||
*/
|
||||
}
|
||||
|
||||
// set invoice to paid
|
||||
$jo->getInvoice()->setStatus(InvoiceStatus::PAID);
|
||||
|
||||
|
|
@ -806,9 +928,8 @@ class RiderAppController extends APIController
|
|||
$phone_number = $jo->getCustomer()->getPhoneMobile();
|
||||
if (!empty($phone_number))
|
||||
{
|
||||
// TODO: put this in config file or somewhere
|
||||
$message = "Your Resq job order has been completed.";
|
||||
$rt->sendSMS($phone_number, 'MOTOLITE', $message);
|
||||
$message = $translator->trans('message.joborder_completed');
|
||||
$rt->sendSMS($phone_number, $translator->trans('message.battery_brand_allcaps'), $message);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
|
@ -816,7 +937,6 @@ class RiderAppController extends APIController
|
|||
// create warranty
|
||||
if($jo_handler->checkIfNewBattery($jo))
|
||||
{
|
||||
$serial = null;
|
||||
$warranty_class = $jo->getWarrantyClass();
|
||||
$first_name = $jo->getCustomer()->getFirstName();
|
||||
$last_name = $jo->getCustomer()->getLastName();
|
||||
|
|
@ -869,6 +989,10 @@ class RiderAppController extends APIController
|
|||
];
|
||||
$mclient->sendEvent($jo, $payload);
|
||||
|
||||
// NOTE: for resq2 app
|
||||
$mclientv2->sendEvent($jo, $payload);
|
||||
$fcmclient->sendJoEvent($jo, "jo_fcm_title_fulfilled", "jo_fcm_body_fulfilled");
|
||||
|
||||
$data = [];
|
||||
return new APIResponse(true, 'Job order paid and fulfilled.', $data);
|
||||
}
|
||||
|
|
@ -896,6 +1020,11 @@ class RiderAppController extends APIController
|
|||
// get rider's current job order
|
||||
$jo = $rider->getCurrentJobOrder();
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// set delivery status
|
||||
$jo->setDeliveryStatus(DeliveryStatus::RIDER_ARRIVE_HUB_POST_JO);
|
||||
|
||||
|
|
@ -937,6 +1066,11 @@ class RiderAppController extends APIController
|
|||
// get rider's current job order
|
||||
$jo = $rider->getCurrentJobOrder();
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// set delivery status
|
||||
$jo->setDeliveryStatus(DeliveryStatus::RIDER_DEPART_HUB_POST_JO);
|
||||
|
||||
|
|
@ -1041,7 +1175,7 @@ class RiderAppController extends APIController
|
|||
if ($rider == null)
|
||||
return new APIResponse(false, 'No rider found.');
|
||||
|
||||
$batts = $em->getRepository(Battery::class)->findAll();
|
||||
$batts = $em->getRepository(Battery::class)->findBy(['flag_active' => true]);
|
||||
$models = $em->getRepository(BatteryModel::class)->findAll();
|
||||
$sizes = $em->getRepository(BatterySize::class)->findAll();
|
||||
|
||||
|
|
@ -1083,9 +1217,180 @@ class RiderAppController extends APIController
|
|||
return new APIResponse(true, 'Batteries found.', $data);
|
||||
}
|
||||
|
||||
public function changeService(Request $req, EntityManagerInterface $em, InvoiceGeneratorInterface $ic)
|
||||
public function getBatteryInfo(Request $req, $serial, EntityManagerInterface $em)
|
||||
{
|
||||
$this->debugRequest($req);
|
||||
if (empty($serial))
|
||||
{
|
||||
return new APIResponse(false, 'Missing parameter(s): serial');
|
||||
}
|
||||
|
||||
// get capi user
|
||||
$capi_user = $this->getUser();
|
||||
if ($capi_user == null)
|
||||
return new APIResponse(false, 'User not found.');
|
||||
|
||||
// get rider id from capi user metadata
|
||||
$rider = $this->getRiderFromCAPI($capi_user, $em);
|
||||
if ($rider == null)
|
||||
return new APIResponse(false, 'No rider found.');
|
||||
|
||||
// find battery given serial/sap_code and flag_active is true
|
||||
$serial = $em->getRepository(WarrantySerial::class)->find($serial);
|
||||
|
||||
if (empty($serial)) {
|
||||
return new APIResponse(false, 'Warranty serial number not found.');
|
||||
}
|
||||
|
||||
$sap_battery = $em->getRepository(SAPBattery::class)->find($serial->getSKU());
|
||||
|
||||
if (empty($sap_battery)) {
|
||||
return new APIResponse(false, 'No battery info found.');
|
||||
}
|
||||
|
||||
$battery = [
|
||||
'id' => $sap_battery->getID(),
|
||||
'brand' => $sap_battery->getBrand()->getName(),
|
||||
'size' => $sap_battery->getSize()->getName(),
|
||||
'size_id' => $sap_battery->getSize()->getID(),
|
||||
'trade_in_type' => TradeInType::MOTOLITE,
|
||||
'container_size' => $sap_battery->getContainerSize()->getName(),
|
||||
];
|
||||
|
||||
return new APIResponse(true, 'Battery info found.', [
|
||||
'battery' => $battery,
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateJobOrder(Request $req, EntityManagerInterface $em, InvoiceGeneratorInterface $ic, PriceTierManager $pt_manager)
|
||||
{
|
||||
$items = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
// get job order id
|
||||
if (!isset($items['jo_id']))
|
||||
return new APIResponse(false, 'Missing parameter(s): jo_id');
|
||||
|
||||
// validate jo_id
|
||||
$jo_id = $items['jo_id'];
|
||||
if (empty($jo_id) || $jo_id == null)
|
||||
return new APIResponse(false, 'Missing parameter(s): jo_id');
|
||||
|
||||
// get capi user
|
||||
$capi_user = $this->getUser();
|
||||
if ($capi_user == null)
|
||||
return new APIResponse(false, 'User not found.');
|
||||
|
||||
// get rider id from capi user metadata
|
||||
$rider = $this->getRiderFromCAPI($capi_user, $em);
|
||||
if ($rider == null)
|
||||
return new APIResponse(false, 'No rider found.');
|
||||
|
||||
// get the job order
|
||||
$jo = $em->getRepository(JobOrder::class)->find($jo_id);
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// check if we have trade in items
|
||||
$ti_items = [];
|
||||
if (isset($items['trade_in_items']))
|
||||
{
|
||||
// validate the trade in items first
|
||||
$ti_items = $items['trade_in_items'];
|
||||
$msg = $this->validateTradeInItems($em, $ti_items);
|
||||
if (!empty($msg))
|
||||
return new APIResponse(false, $msg);
|
||||
}
|
||||
|
||||
// get the service type
|
||||
if (!isset($items['stype_id']))
|
||||
return new APIResponse(false, 'Missing parameter(s): stype_id');
|
||||
|
||||
// validate service type
|
||||
$stype_id = $items['stype_id'];
|
||||
if (!ServiceType::validate($stype_id))
|
||||
return new APIResponse(false, 'Invalid service type - ' . $stype_id);
|
||||
|
||||
// save service type
|
||||
$jo->setServiceType($stype_id);
|
||||
|
||||
// validate promo if any. Promo not required
|
||||
$promo = null;
|
||||
if (isset($items['promo_id']))
|
||||
{
|
||||
$promo_id = $items['promo_id'];
|
||||
$promo = $em->getRepository(Promo::class)->find($promo_id);
|
||||
if ($promo == null)
|
||||
return new APIResponse(false, 'Invalid promo id - ' . $promo_id);
|
||||
}
|
||||
|
||||
// get other parameters, if any: has motolite battery, has warranty doc, with coolant, payment method, with sealant
|
||||
if (isset($items['flag_motolite_battery']))
|
||||
{
|
||||
// get customer vehicle from jo
|
||||
$cv = $jo->getCustomerVehicle();
|
||||
$has_motolite = $items['flag_motolite_battery'];
|
||||
if ($has_motolite == 'true')
|
||||
$cv->setHasMotoliteBattery(true);
|
||||
else
|
||||
$cv->setHasMotoliteBattery(false);
|
||||
|
||||
$em->persist($cv);
|
||||
|
||||
}
|
||||
if (isset($items['flag_warranty_doc']))
|
||||
{
|
||||
// TODO: what do we do?
|
||||
}
|
||||
if (isset($items['flag_coolant']))
|
||||
{
|
||||
$has_coolant = $items['flag_coolant'];
|
||||
if ($has_coolant == 'true')
|
||||
$jo->setHasCoolant(true);
|
||||
else
|
||||
$jo->setHasCoolant(false);
|
||||
|
||||
}
|
||||
if (isset($items['mode_of_payment']))
|
||||
{
|
||||
$payment_method = $items['payment_method'];
|
||||
if (!ModeOfPayment::validate($payment_method))
|
||||
$payment_method = ModeOfPayment::CASH;
|
||||
$jo->setModeOfPayment($payment_method);
|
||||
}
|
||||
|
||||
if (isset($items['flag_sealant']))
|
||||
{
|
||||
$has_sealant = $items['flag_sealant'];
|
||||
if ($has_sealant == 'true')
|
||||
$jo->setHasSealant(true);
|
||||
else
|
||||
$jo->setHasSealant(false);
|
||||
}
|
||||
|
||||
// get capi user
|
||||
$capi_user = $this->getUser();
|
||||
if ($capi_user == null)
|
||||
return new APIResponse(false, 'User not found.');
|
||||
|
||||
// get rider id from capi user metadata
|
||||
$rider = $this->getRiderFromCAPI($capi_user, $em);
|
||||
if ($rider == null)
|
||||
return new APIResponse(false, 'No rider found.');
|
||||
|
||||
// need to get the existing invoice items using jo id and invoice id
|
||||
$existing_ii = $this->getInvoiceItems($em, $jo);
|
||||
|
||||
$this->generateUpdatedInvoice($em, $ic, $jo, $existing_ii, $ti_items, $promo, $pt_manager);
|
||||
|
||||
$data = [];
|
||||
return new APIResponse(true, 'Job order updated.', $data);
|
||||
}
|
||||
|
||||
public function changeService(Request $req, EntityManagerInterface $em, InvoiceGeneratorInterface $ic, PriceTierManager $pt_manager)
|
||||
{
|
||||
// $this->debugRequest($req);
|
||||
|
||||
// allow rider to change service, promo, battery and trade-in options
|
||||
$required_params = ['jo_id', 'stype_id', 'promo_id'];
|
||||
|
|
@ -1104,6 +1409,11 @@ class RiderAppController extends APIController
|
|||
if (!empty($msg))
|
||||
return new APIResponse(false, $msg);
|
||||
|
||||
// check if JO can be modified first
|
||||
if (!$this->checkJOProgressionAllowed($em, $jo, $rider)) {
|
||||
return new APIResponse(false, 'Job order can no longer be modified.');
|
||||
}
|
||||
|
||||
// check service type
|
||||
$stype_id = $req->request->get('stype_id');
|
||||
if (!ServiceType::validate($stype_id))
|
||||
|
|
@ -1143,6 +1453,13 @@ class RiderAppController extends APIController
|
|||
else
|
||||
$jo->setHasCoolant(false);
|
||||
|
||||
// sealant
|
||||
$flag_sealant = $req->request->get('flag_sealant', 'false');
|
||||
if ($flag_sealant == 'true')
|
||||
$jo->setHasSealant(true);
|
||||
else
|
||||
$jo->setHasSealant(false);
|
||||
|
||||
// has motolite battery
|
||||
$cv = $jo->getCustomerVehicle();
|
||||
$has_motolite = $req->request->get('has_motolite', 'false');
|
||||
|
|
@ -1185,6 +1502,11 @@ class RiderAppController extends APIController
|
|||
$crit->setServiceType($stype_id);
|
||||
$crit->setCustomerVehicle($cv);
|
||||
$crit->setHasCoolant($jo->hasCoolant());
|
||||
$crit->setIsTaxable();
|
||||
|
||||
// set price tier
|
||||
$pt_id = $pt_manager->getPriceTier($jo->getCoordinates());
|
||||
$crit->setPriceTier($pt_id);
|
||||
|
||||
if ($promo != null)
|
||||
$crit->addPromo($promo);
|
||||
|
|
@ -1192,7 +1514,7 @@ class RiderAppController extends APIController
|
|||
if ($battery != null)
|
||||
{
|
||||
$crit->addEntry($battery, $trade_in, 1);
|
||||
error_log('adding entry for battery - ' . $battery->getID());
|
||||
// error_log('adding entry for battery - ' . $battery->getID());
|
||||
}
|
||||
|
||||
$invoice = $ic->generateInvoice($crit);
|
||||
|
|
@ -1224,6 +1546,168 @@ class RiderAppController extends APIController
|
|||
return new APIResponse(true, 'Job order service changed.', $data);
|
||||
}
|
||||
|
||||
protected function generateUpdatedInvoice(EntityManagerInterface $em, InvoiceGeneratorInterface $ic, JobOrder $jo, $existing_ii, $trade_in_items, $promo, PriceTierManager $pt_manager)
|
||||
{
|
||||
// get the service type
|
||||
$stype = $jo->getServiceType();
|
||||
|
||||
// get the source
|
||||
$source = $jo->getSource();
|
||||
|
||||
// get the customer vehicle
|
||||
$cv = $jo->getCustomerVehicle();
|
||||
|
||||
// get coolant if any
|
||||
$flag_coolant = $jo->hasCoolant();
|
||||
|
||||
// get sealant if any
|
||||
$flag_sealant = $jo->hasSealant();
|
||||
|
||||
// check if new promo is null
|
||||
if ($promo == null)
|
||||
{
|
||||
// promo not updated from app so check existing invoice
|
||||
// get the promo id from existing invoice item
|
||||
$promo_id = $existing_ii['promo_id'];
|
||||
if ($promo_id == null)
|
||||
$promo = null;
|
||||
else
|
||||
$promo = $em->getRepository(Promo::class)->find($promo_id);
|
||||
}
|
||||
|
||||
// populate Invoice Criteria
|
||||
$icrit = new InvoiceCriteria();
|
||||
$icrit->setServiceType($stype)
|
||||
->setCustomerVehicle($cv)
|
||||
->setSource($source)
|
||||
->setHasCoolant($flag_coolant)
|
||||
->setHasSealant($flag_sealant)
|
||||
->setIsTaxable();
|
||||
|
||||
// set price tier
|
||||
$pt_id = $pt_manager->getPriceTier($jo->getCoordinates());
|
||||
$icrit->setPriceTier($pt_id);
|
||||
|
||||
// at this point, all information should be valid
|
||||
// assuming JO information is already valid since this
|
||||
// is in the system already
|
||||
// add promo if any to criteria
|
||||
if ($promo != null)
|
||||
$icrit->addPromo($promo);
|
||||
|
||||
// get the battery purchased from existing invoice items
|
||||
// add the batteries ordered to criteria
|
||||
$ii_items = $existing_ii['invoice_items'];
|
||||
foreach ($ii_items as $ii_item)
|
||||
{
|
||||
$batt_id = $ii_item['batt_id'];
|
||||
$qty = $ii_item['qty'];
|
||||
|
||||
$battery = $em->getRepository(Battery::class)->find($batt_id);
|
||||
|
||||
$icrit->addEntry($battery, null, $qty);
|
||||
}
|
||||
|
||||
// add the trade in items to the criteria
|
||||
foreach ($trade_in_items as $ti_item)
|
||||
{
|
||||
$batt_size_id = $ti_item['battery_size_id'];
|
||||
$qty = $ti_item['qty'];
|
||||
$trade_in_type = $ti_item['trade_in_type'];
|
||||
|
||||
$batt_size = $em->getRepository(BatterySize::class)->find($batt_size_id);
|
||||
|
||||
$icrit->addTradeInEntry($batt_size, $trade_in_type, $qty);
|
||||
}
|
||||
|
||||
// call generateInvoice
|
||||
$invoice = $ic->generateInvoice($icrit);
|
||||
|
||||
// remove previous invoice
|
||||
$old_invoice = $jo->getInvoice();
|
||||
$em->remove($old_invoice);
|
||||
$em->flush();
|
||||
|
||||
// save new invoice
|
||||
$jo->setInvoice($invoice);
|
||||
$em->persist($invoice);
|
||||
|
||||
// log event?
|
||||
$event = new JOEvent();
|
||||
$event->setDateHappen(new DateTime())
|
||||
->setTypeID(JOEventType::RIDER_EDIT)
|
||||
->setJobOrder($jo)
|
||||
->setRider($jo->getRider());
|
||||
$em->persist($event);
|
||||
|
||||
$em->flush();
|
||||
}
|
||||
|
||||
protected function getInvoiceItems(EntityManagerInterface $em, JobOrder $jo)
|
||||
{
|
||||
$jo_id = $jo->getID();
|
||||
$conn = $em->getConnection();
|
||||
|
||||
// need to get the ordered battery id and quantity from invoice item
|
||||
// and the promo from invoice
|
||||
$query_sql = 'SELECT ii.battery_id AS battery_id, ii.qty AS qty, i.promo_id AS promo_id
|
||||
FROM invoice_item ii, invoice i
|
||||
WHERE ii.invoice_id = i.id
|
||||
AND i.job_order_id = :jo_id
|
||||
AND ii.battery_id IS NOT NULL';
|
||||
|
||||
$query_stmt = $conn->prepare($query_sql);
|
||||
$query_stmt->bindValue('jo_id', $jo_id);
|
||||
|
||||
$results = $query_stmt->executeQuery();
|
||||
|
||||
$promo_id = null;
|
||||
$invoice_items = [];
|
||||
while ($row = $results->fetchAssociative())
|
||||
{
|
||||
$promo_id = $row['promo_id'];
|
||||
$invoice_items[] = [
|
||||
'batt_id' => $row['battery_id'],
|
||||
'qty' => $row['qty'],
|
||||
'trade_in' => ''
|
||||
];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'promo_id' => $promo_id,
|
||||
'invoice_items' => $invoice_items
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function validateTradeInItems(EntityManagerInterface $em, $ti_items)
|
||||
{
|
||||
$msg = '';
|
||||
foreach ($ti_items as $ti_item)
|
||||
{
|
||||
$bs_id = $ti_item['battery_size_id'];
|
||||
$ti_type = $ti_item['trade_in_type'];
|
||||
|
||||
// validate the battery size id
|
||||
$batt_size = $em->getRepository(BatterySize::class)->find($bs_id);
|
||||
if ($batt_size == null)
|
||||
{
|
||||
$msg = 'Invalid battery size for trade in: ' . $bs_id;
|
||||
return $msg;
|
||||
}
|
||||
|
||||
// validate the trade in type
|
||||
if (!TradeInType::validate($ti_type))
|
||||
{
|
||||
$msg = 'Invalid trade in type: ' . $ti_type;
|
||||
return $msg;
|
||||
}
|
||||
}
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
protected function getCAPIUser($id, EntityManagerInterface $em)
|
||||
{
|
||||
$capi_user = $em->getRepository(APIUser::class)->find($id);
|
||||
|
|
@ -1303,6 +1787,42 @@ class RiderAppController extends APIController
|
|||
return $msg;
|
||||
}
|
||||
|
||||
protected function checkJOProgressionAllowed(EntityManagerInterface $em, JobOrder $jo, &$rider)
|
||||
{
|
||||
$allowed = true;
|
||||
|
||||
error_log("JO delivery status is " . $jo->getDeliveryStatus() . " (not allowed: " . DeliveryStatus::CANCELLED . ")");
|
||||
error_log("JO status is " . $jo->getStatus() . " (not allowed: " . JOStatus::CANCELLED . ")");
|
||||
|
||||
// TODO: add more statuses to block if needed, hence. this is a failsafe in case MQTT is not working.
|
||||
// check delivery status
|
||||
switch ($jo->getDeliveryStatus())
|
||||
{
|
||||
case DeliveryStatus::CANCELLED:
|
||||
$allowed = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// check JO status as well
|
||||
switch ($jo->getStatus())
|
||||
{
|
||||
case JOStatus::CANCELLED:
|
||||
$allowed = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// if this is the rider's current JO, set to null
|
||||
if (!$allowed) {
|
||||
if ($rider->getCurrentJobOrder() === $jo) {
|
||||
$rider->setCurrentJobOrder();
|
||||
$em->persist($rider);
|
||||
$em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
return $allowed;
|
||||
}
|
||||
|
||||
protected function debugRequest(Request $req)
|
||||
{
|
||||
$all = $req->request->all();
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ namespace App\Controller\CAPI;
|
|||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\ORM\Query;
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Response\APIResponse;
|
||||
|
||||
class TestController extends APIController
|
||||
class TestController extends ApiController
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
|
|
@ -17,4 +17,19 @@ class TestController extends APIController
|
|||
];
|
||||
return new APIResponse(true, 'Test successful.', $data);
|
||||
}
|
||||
|
||||
public function warrantySerial(Request $req)
|
||||
{
|
||||
error_log('Got request');
|
||||
|
||||
$res = json_decode($req->getContent(), true);
|
||||
|
||||
// return $res;
|
||||
|
||||
$data = [
|
||||
'result' => $res,
|
||||
];
|
||||
return new APIResponse(true, 'Test successful.', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,14 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
use App\Entity\Vehicle;
|
||||
use App\Entity\VehicleManufacturer;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
class VehicleController extends APIController
|
||||
class VehicleController extends ApiController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ class VehicleController extends APIController
|
|||
{
|
||||
$this->denyAccessUnlessGranted('vehicle.list', null, 'No access.');
|
||||
|
||||
$mfg = $this->em->getRepository(VehicleManufacturer::class)->find($mfg_id);
|
||||
$mfg = $em->getRepository(VehicleManufacturer::class)->find($mfg_id);
|
||||
|
||||
// manufacturer not found
|
||||
if ($mfg == null)
|
||||
|
|
@ -69,6 +69,9 @@ class VehicleController extends APIController
|
|||
}
|
||||
|
||||
// TODO: need to add manufacturer details
|
||||
$data = [
|
||||
'vehicles' => $make_data,
|
||||
];
|
||||
|
||||
return new APIResponse(true, 'Vehicles loaded.', $data);
|
||||
}
|
||||
|
|
@ -77,31 +80,48 @@ class VehicleController extends APIController
|
|||
{
|
||||
$this->denyAccessUnlessGranted('vehicle.list', null, 'No access.');
|
||||
|
||||
$conn = $em->getConnection();
|
||||
// get manufacturers
|
||||
$mfgs = $em->getRepository(VehicleManufacturer::class)->findBy([], ['name' => 'ASC']);
|
||||
$mfg_sql = 'SELECT vmfg.id, vmfg.name FROM vehicle_manufacturer vmfg ORDER BY vmfg.name ASC';
|
||||
|
||||
// get manufacturer results
|
||||
$mfg_stmt = $conn->prepare($mfg_sql);
|
||||
$mfg_stmt->execute();
|
||||
|
||||
$mfg_results = $mfg_stmt->fetchAll();
|
||||
|
||||
// get vehicles
|
||||
$vehicles = $em->getRepository(Vehicle::class)->findBy([], ['manufacturer' => 'ASC', 'make' => 'ASC']);
|
||||
$vehicle_sql = 'SELECT v.id, v.manufacturer_id, v.make, v.model_year_from, v.model_year_to
|
||||
FROM vehicle v ORDER BY v.manufacturer_id ASC, v.make ASC';
|
||||
|
||||
// get vehicle results
|
||||
$vehicle_stmt = $conn->prepare($vehicle_sql);
|
||||
$vehicle_stmt->execute();
|
||||
|
||||
$vehicle_results = $vehicle_stmt->fetchAll();
|
||||
|
||||
// process manufacturer results
|
||||
$mfg_data = [];
|
||||
foreach($mfgs as $mfg)
|
||||
foreach($mfg_results as $mfg_row)
|
||||
{
|
||||
$mfg_data[] = [
|
||||
'id' => $mfg->getID(),
|
||||
'name' => $mfg->getName(),
|
||||
'id' => $mfg_row['id'],
|
||||
'name' => $mfg_row['name'],
|
||||
];
|
||||
}
|
||||
|
||||
// process vehicle results
|
||||
$make_data = [];
|
||||
foreach($vehicles as $vehicle)
|
||||
foreach($vehicle_results as $vrow)
|
||||
{
|
||||
// format the model year from and model year to
|
||||
$model_year = $vrow['model_year_from' ] . ' - ' . $vrow['model_year_to'];
|
||||
|
||||
$make_data[] = [
|
||||
'id' => $vehicle->getID(),
|
||||
'mfg_id' => $vehicle->getManufacturer()->getID(),
|
||||
'make' => $vehicle->getMake(),
|
||||
'model' => $vehicle->getModelYearFormatted(),
|
||||
'id' => $vrow['id'],
|
||||
'mfg_id' => $vrow['manufacturer_id'],
|
||||
'make' => $vrow['make'],
|
||||
'model' => $model_year,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Catalyst\APIBundle\Controller\APIController;
|
||||
use Catalyst\APIBundle\Response\APIResponse;
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
|
||||
use App\Entity\Warranty;
|
||||
use App\Entity\BatteryModel;
|
||||
|
|
@ -33,10 +33,10 @@ use App\Ramcar\WarrantySource;
|
|||
|
||||
use DateTime;
|
||||
|
||||
use Catalyst\APIBundle\Access\Generator as ACLGenerator;
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
// third party API
|
||||
class WarrantyController extends APIController
|
||||
class WarrantyController extends ApiController
|
||||
{
|
||||
protected $acl_gen;
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ class WarrantyController extends APIController
|
|||
$source = 'CAPI_USER_' . $username;
|
||||
|
||||
$msg = $this->checkRequiredParameters($req, $params);
|
||||
error_log('msg - ' . $msg);
|
||||
// error_log('msg - ' . $msg);
|
||||
if ($msg)
|
||||
{
|
||||
$logger->logWarrantyInfo($log_data, $msg, $user_id, $action, $source);
|
||||
|
|
@ -330,7 +330,7 @@ class WarrantyController extends APIController
|
|||
|
||||
// get the api_user that made the call so that it gets added to the source
|
||||
// source becomes CAPI_USER_<insert name of api user here>
|
||||
$username = $this->getAPIUsername($em, $user_id);
|
||||
$username = $this->getUser()->getName();
|
||||
$source = 'CAPI_USER_' . $username;
|
||||
|
||||
|
||||
|
|
@ -434,7 +434,7 @@ class WarrantyController extends APIController
|
|||
];
|
||||
|
||||
$msg = $this->checkRequiredParameters($req, $params);
|
||||
error_log('msg - ' . $msg);
|
||||
// error_log('msg - ' . $msg);
|
||||
if ($msg)
|
||||
return new APIResponse(false, $msg);
|
||||
|
||||
|
|
@ -567,7 +567,7 @@ class WarrantyController extends APIController
|
|||
];
|
||||
|
||||
$msg = $this->checkRequiredParameters($req, $params);
|
||||
error_log('msg - ' . $msg);
|
||||
// error_log('msg - ' . $msg);
|
||||
if ($msg)
|
||||
return new APIResponse(false, $msg);
|
||||
|
||||
|
|
@ -600,14 +600,14 @@ class WarrantyController extends APIController
|
|||
{
|
||||
$this->denyAccessUnlessGranted('warranty.list.serial', null, 'No access.');
|
||||
|
||||
error_log('getWarrantiesBySerialList');
|
||||
// error_log('getWarrantiesBySerialList');
|
||||
// required parameters
|
||||
$params = [
|
||||
'serial_list',
|
||||
];
|
||||
|
||||
$msg = $this->checkRequiredParameters($req, $params);
|
||||
error_log('msg - ' . $msg);
|
||||
// error_log('msg - ' . $msg);
|
||||
if ($msg)
|
||||
return new APIResponse(false, $msg);
|
||||
|
||||
|
|
@ -658,7 +658,7 @@ class WarrantyController extends APIController
|
|||
{
|
||||
// remove first '0'
|
||||
$w_mobile_num = substr($w_mobile_num, 1);
|
||||
error_log("CONVERTED TO $w_mobile_num");
|
||||
// error_log("CONVERTED TO $w_mobile_num");
|
||||
}
|
||||
|
||||
// does it fit our 9XXXXXXXXX pattern?
|
||||
|
|
@ -678,7 +678,7 @@ class WarrantyController extends APIController
|
|||
|
||||
if (!empty($customers))
|
||||
{
|
||||
error_log('found customer for ' . $w_mobile_num);
|
||||
// error_log('found customer for ' . $w_mobile_num);
|
||||
foreach ($customers as $customer)
|
||||
{
|
||||
// get customer vehicles for customer
|
||||
|
|
@ -707,13 +707,13 @@ class WarrantyController extends APIController
|
|||
if ($cv_found)
|
||||
{
|
||||
// vehicle found, do nothing.
|
||||
error_log('vehicle found - ' . $w_plate_number);
|
||||
// error_log('vehicle found - ' . $w_plate_number);
|
||||
}
|
||||
else
|
||||
{
|
||||
// customer exists but not customer vehicle
|
||||
// add customer vehicle to existing customer with unknown manufacturer and make
|
||||
error_log('new vehicle - ' . $w_plate_number);
|
||||
// error_log('new vehicle - ' . $w_plate_number);
|
||||
$this->createCustomerVehicle($em, $customer, $this->getDefaultVehicle($em), $w_plate_number);
|
||||
}
|
||||
}
|
||||
|
|
@ -721,7 +721,7 @@ class WarrantyController extends APIController
|
|||
// customer not found
|
||||
else
|
||||
{
|
||||
error_log('NEW customer and vehicle - ' . $w_plate_number);
|
||||
// error_log('NEW customer and vehicle - ' . $w_plate_number);
|
||||
// customer not found, add customer and customer vehicle
|
||||
// get warranty first name, last name
|
||||
$w_first_name = $warranty->getFirstName();
|
||||
|
|
|
|||
182
src/Controller/CAPI/WarrantySerialController.php
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CAPI;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Doctrine\ORM\Query;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
|
||||
use Catalyst\ApiBundle\Controller\ApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as APIResponse;
|
||||
|
||||
use App\Entity\WarrantySerialQueue;
|
||||
|
||||
use App\Service\WarrantySerialUploadLogger;
|
||||
|
||||
use DateTime;
|
||||
|
||||
use Catalyst\AuthBundle\Service\ACLGenerator as ACLGenerator;
|
||||
|
||||
// third party API
|
||||
class WarrantySerialController extends ApiController
|
||||
{
|
||||
protected $acl_gen;
|
||||
protected $upload_logger;
|
||||
|
||||
public function __construct(ACLGenerator $acl_gen, WarrantySerialUploadLogger $upload_logger)
|
||||
{
|
||||
$this->acl_gen = $acl_gen;
|
||||
$this->upload_logger = $upload_logger;
|
||||
}
|
||||
|
||||
public function uploadWarrantySerialFile(Request $req, EntityManagerInterface $em, KernelInterface $kernel)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('warrantyserial.upload', null, 'No access.');
|
||||
|
||||
$required_params = [
|
||||
'serial_file',
|
||||
];
|
||||
|
||||
$user_id = $_SERVER['HTTP_X_CATA_API_KEY'];
|
||||
|
||||
$res = $this->checkRequiredParamsForFiles($req, $required_params, $user_id);
|
||||
|
||||
if ($res !== true)
|
||||
return $res;
|
||||
|
||||
// get the csv file
|
||||
$csv_file = $req->files->get('serial_file');
|
||||
|
||||
// process file upload
|
||||
$upload_dir = $kernel->getProjectDir() . '/public/warranty_serial_uploads';
|
||||
$serial_filename = $this->handleSerialFileUpload($csv_file, $upload_dir);
|
||||
|
||||
// insert to warranty serial queue
|
||||
$res = $this->registerWarrantySerialFile($em, $csv_file, $serial_filename, $user_id);
|
||||
|
||||
// flush to db
|
||||
$em->flush();
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
protected function registerWarrantySerialFile($em, $file, $serial_filename, $user_id)
|
||||
{
|
||||
// parse the serial filename to get the file id
|
||||
$parts = explode('/', $serial_filename);
|
||||
$file_id = $parts[0];
|
||||
$orig_filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME) . '.' . $file->getClientOriginalExtension();
|
||||
|
||||
$ws_file = new WarrantySerialQueue();
|
||||
|
||||
$ws_file->setFileSerial($serial_filename)
|
||||
->setStatus('pending')
|
||||
->setOrigFileSerial($orig_filename)
|
||||
->setFileID($file_id)
|
||||
->setApiUser($user_id);
|
||||
|
||||
$em->persist($ws_file);
|
||||
|
||||
// log upload
|
||||
$log_data = [
|
||||
'user_id' => $user_id,
|
||||
'is_uploaded' => true,
|
||||
'orig_file_serial' => $orig_filename,
|
||||
'uploaded_file_serial' => $serial_filename,
|
||||
];
|
||||
|
||||
$this->upload_logger->logWarrantySerialUploadInfo($log_data);
|
||||
|
||||
$data = [
|
||||
'id' => $file_id,
|
||||
];
|
||||
|
||||
return new APIResponse(true, 'Warranty serial file uploaded.', $data);
|
||||
}
|
||||
|
||||
protected function handleSerialFileUpload($file, $target_dir)
|
||||
{
|
||||
// create target dir if it doesn't exist
|
||||
if (!file_exists($target_dir))
|
||||
{
|
||||
if (!mkdir($target_dir, 0744, true))
|
||||
{
|
||||
$log_data = [
|
||||
'user_id' => $user_id,
|
||||
'is_uploaded' => false,
|
||||
'error' => 'Failed to create folder for warranty serial files.'
|
||||
];
|
||||
|
||||
$this->upload_logger->logWarrantySerialUploadInfo($log_data);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// get current date
|
||||
$curr_date = new DateTime();
|
||||
$str_curr_date = $curr_date->format('Ymd');
|
||||
$file_id = $str_curr_date . uniqid();
|
||||
|
||||
// move file
|
||||
$filename = 'warranty_serial' . '.' . $file->getClientOriginalExtension();
|
||||
$file->move($target_dir . '/' . $file_id, $filename);
|
||||
|
||||
return $file_id . '/' . $filename;
|
||||
}
|
||||
|
||||
protected function checkRequiredParamsForFiles(Request $req, $params, $user_id)
|
||||
{
|
||||
// check required parameters
|
||||
$missing = $this->checkMissingParametersForFiles($req, $params);
|
||||
if (count($missing) > 0)
|
||||
{
|
||||
// log the error
|
||||
$miss_string = implode(', ', $missing);
|
||||
$log_data = [
|
||||
'user_id' => $user_id,
|
||||
'is_uploaded' => false,
|
||||
'error' => 'Missing parameter(s): ' . $miss_string
|
||||
];
|
||||
|
||||
$this->upload_logger->logWarrantySerialUploadInfo($log_data);
|
||||
|
||||
return new APIResponse(false, 'Missing parameter(s): ' . $miss_string);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function checkMissingParametersForFiles(Request $req, $params = [])
|
||||
{
|
||||
$missing = [];
|
||||
|
||||
// check if parameters are there
|
||||
foreach ($params as $param)
|
||||
{
|
||||
if ($req->getMethod() == 'GET')
|
||||
{
|
||||
$check = $req->query->get($param);
|
||||
if (empty($check))
|
||||
$missing[] = $param;
|
||||
}
|
||||
else if ($req->getMethod() == 'POST')
|
||||
{
|
||||
// get files from request.
|
||||
$check = $req->files->get($param);
|
||||
if (empty($check))
|
||||
{
|
||||
$missing[] = $param;
|
||||
}
|
||||
}
|
||||
else
|
||||
return $params;
|
||||
}
|
||||
|
||||
return $missing;
|
||||
}
|
||||
}
|
||||
207
src/Controller/CustomerAppAPI/AccountController.php
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CustomerAppAPI;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
||||
use App\Entity\CustomerDeleteRequest;
|
||||
use App\Entity\Customer;
|
||||
use App\Service\RisingTideGateway;
|
||||
use DateTime;
|
||||
|
||||
class AccountController extends ApiController
|
||||
{
|
||||
public function deleteAccount(RisingTideGateway $rt, Request $req, TranslatorInterface $translator)
|
||||
{
|
||||
// validate params
|
||||
$missing = $this->hasMissingParams($req, [
|
||||
'phone_number',
|
||||
]);
|
||||
|
||||
if ($missing) {
|
||||
return new ApiResponse(false, $missing);
|
||||
}
|
||||
|
||||
// user input
|
||||
$phone_number = $req->request->get('phone_number');
|
||||
$reason = $req->request->get('reason');
|
||||
|
||||
// use the test code if we're using a test number or are on test mode
|
||||
$code = $this->getConfirmCode($phone_number);
|
||||
|
||||
$success_msg = 'We have sent a confirmation code to the submitted phone number if it is valid.';
|
||||
|
||||
// initialize model
|
||||
$obj = new CustomerDeleteRequest();
|
||||
|
||||
// check if a customer record exists for this phone number
|
||||
$cust_obj = $this->findCustomerByNumber($phone_number);
|
||||
if (empty($cust_obj)) {
|
||||
// return a random id anyway if we don't find this customer
|
||||
return new ApiResponse(true, $success_msg, [
|
||||
'request_id' => $obj->getID(),
|
||||
]);
|
||||
}
|
||||
|
||||
// phone number is valid, we continue building the model
|
||||
$obj->setPhoneNumber($phone_number);
|
||||
$obj->setReason($reason);
|
||||
$obj->setConfirmCode($code);
|
||||
|
||||
// send sms to number if not in test mode
|
||||
if ($this->getOtpMode() != 'test') {
|
||||
$this->sendConfirmationCode($rt, $phone_number, $code, $translator);
|
||||
}
|
||||
|
||||
// save the model
|
||||
$obj->setDateCodeSent(new DateTime());
|
||||
$this->em->persist($obj);
|
||||
$this->em->flush();
|
||||
|
||||
// response
|
||||
return new ApiResponse(true, $success_msg, [
|
||||
'request_id' => $obj->getID(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function validateDeleteCode(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$missing = $this->hasMissingParams($req, [
|
||||
'request_id',
|
||||
'code',
|
||||
]);
|
||||
|
||||
if ($missing) {
|
||||
return new ApiResponse(false, $missing);
|
||||
}
|
||||
|
||||
// user input
|
||||
$code = $req->request->get('code');
|
||||
$request_id = $req->request->get('request_id');
|
||||
|
||||
// get the request
|
||||
$obj = $this->em->getRepository(CustomerDeleteRequest::class)->findOneBy([
|
||||
'id' => $request_id,
|
||||
'confirm_code' => $code,
|
||||
'flag_confirmed' => false,
|
||||
'flag_completed' => false,
|
||||
]);
|
||||
if (empty($obj)) {
|
||||
return new ApiResponse(false, 'Your confirmation code is invalid.');
|
||||
}
|
||||
|
||||
// check if a customer record exists for this phone number
|
||||
$cust_obj = $this->findCustomerByNumber($obj->getPhoneNumber());
|
||||
if (empty($cust_obj)) {
|
||||
return new ApiResponse(false, 'No account exists for this phone number.');
|
||||
}
|
||||
|
||||
// confirm the request
|
||||
$obj->setConfirmed(true);
|
||||
$obj->setDateConfirmed(new DateTime());
|
||||
$obj->setCustomer($cust_obj);
|
||||
$this->em->flush();
|
||||
|
||||
// response
|
||||
return new ApiResponse(true, 'Your request has been submitted for processing.');
|
||||
}
|
||||
|
||||
public function resendCode(Request $req, RisingTideGateway $rt, TranslatorInterface $translator)
|
||||
{
|
||||
// validate params
|
||||
$missing = $this->hasMissingParams($req, [
|
||||
'request_id',
|
||||
]);
|
||||
|
||||
if ($missing) {
|
||||
return new ApiResponse(false, $missing);
|
||||
}
|
||||
|
||||
// user input
|
||||
$request_id = $req->request->get('request_id');
|
||||
$now = time();
|
||||
|
||||
// get the request
|
||||
$obj = $this->em->getRepository(CustomerDeleteRequest::class)->findOneBy([
|
||||
'id' => $request_id,
|
||||
'flag_confirmed' => false,
|
||||
'flag_completed' => false,
|
||||
]);
|
||||
if (empty($obj)) {
|
||||
return new ApiResponse(false, 'Invalid request details provided.');
|
||||
}
|
||||
|
||||
// prevent resend spamming
|
||||
if ($now - $obj->getDateCodeSent()->getTimestamp() < 300) {
|
||||
return new ApiResponse(false, 'You can only request a confirm code every 5 mins.');
|
||||
}
|
||||
|
||||
$success_msg = 'We have re-sent a confirmation code to the submitted phone number if it is valid.';
|
||||
|
||||
// check if a customer record exists for this phone number
|
||||
$cust_obj = $this->findCustomerByNumber($obj->getPhoneNumber());
|
||||
if (empty($cust_obj)) {
|
||||
// return successful without resending code if we don't find this customer
|
||||
return new ApiResponse(true, $success_msg);
|
||||
}
|
||||
|
||||
// use the test code if we're using a test number or are on test mode
|
||||
$phone_number = $obj->getPhoneNumber();
|
||||
$code = $this->getConfirmCode($phone_number);
|
||||
|
||||
// send sms to number if not in test mode
|
||||
if ($this->getOtpMode()!= 'test') {
|
||||
$this->sendConfirmationCode($rt, $phone_number, $code, $translator);
|
||||
}
|
||||
|
||||
// update last sent timestamp
|
||||
$obj->setDateCodeSent(new DateTime());
|
||||
$this->em->flush();
|
||||
|
||||
// response
|
||||
return new ApiResponse(true, $success_msg);
|
||||
}
|
||||
|
||||
protected function getConfirmCode($phone_number)
|
||||
{
|
||||
// check for hardcoded phone number for app store testing
|
||||
$test_numbers = explode(",", $_ENV['TEST_PHONE_NUMBERS']);
|
||||
|
||||
if (in_array($phone_number, $test_numbers) || $this->getOtpMode() == 'test') {
|
||||
$code = "123456";
|
||||
} else {
|
||||
// generate code
|
||||
$code = $this->generateConfirmCode();
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
protected function generateConfirmCode()
|
||||
{
|
||||
return sprintf("%06d", mt_rand(100000, 999999));
|
||||
}
|
||||
|
||||
protected function sendConfirmationCode(RisingTideGateway $rt, $phone_number, $code, TranslatorInterface $translator)
|
||||
{
|
||||
// send sms to number
|
||||
$message = $translator->trans('message.confirmation_code') . ' ' . $code;
|
||||
$rt->sendSMS($phone_number, $translator->trans('message.battery_brand_allcaps'), $message);
|
||||
}
|
||||
|
||||
protected function findCustomerByNumber($number)
|
||||
{
|
||||
$cust_obj = $this->em->getRepository(Customer::class)->findOneBy([
|
||||
'phone_mobile' => $number,
|
||||
]);
|
||||
|
||||
return $cust_obj;
|
||||
}
|
||||
|
||||
protected function getOtpMode()
|
||||
{
|
||||
return $_ENV['OTP_MODE'];
|
||||
}
|
||||
}
|
||||
167
src/Controller/CustomerAppAPI/ApiController.php
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CustomerAppAPI;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Catalyst\ApiBundle\Controller\ApiController as BaseApiController;
|
||||
use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
||||
|
||||
use App\Ramcar\JOStatus;
|
||||
use App\Entity\Warranty;
|
||||
use App\Entity\JobOrder;
|
||||
use App\Entity\CustomerSession;
|
||||
|
||||
class ApiController extends BaseApiController
|
||||
{
|
||||
protected $em;
|
||||
protected $session;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, KernelInterface $kernel)
|
||||
{
|
||||
$this->session = new CustomerSession; // NOTE: original was null
|
||||
$this->em = $em;
|
||||
|
||||
// load env file
|
||||
$dotenv = new Dotenv();
|
||||
$dotenv->loadEnv($kernel->getProjectDir() . '/.env');
|
||||
}
|
||||
|
||||
protected function debugRequest(Request $req)
|
||||
{
|
||||
$all = $req->request->all();
|
||||
error_log(print_r($all, true));
|
||||
}
|
||||
|
||||
protected function hasMissingParams(Request $req, $params = [])
|
||||
{
|
||||
return $this->checkRequiredParameters($req, $params);
|
||||
}
|
||||
|
||||
protected function validateSession($session_key)
|
||||
{
|
||||
// check if the session exists
|
||||
$session = $this->em->getRepository(CustomerSession::class)->find($session_key);
|
||||
if ($session === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->session = $session;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function validateRequest(Request $req, $params = [])
|
||||
{
|
||||
$error = $this->hasMissingParams($req, $params);
|
||||
$session_key = $req->query->get('session_key');
|
||||
|
||||
if (!$error) {
|
||||
if (empty($session_key) || !$this->validateSession($session_key)) {
|
||||
$error = 'Invalid session key.';
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'is_valid' => !$error,
|
||||
'error' => $error,
|
||||
];
|
||||
}
|
||||
|
||||
protected function findWarranty($plate_number)
|
||||
{
|
||||
// NOTE: Modify the search for the latest warranty. This seems hacky.
|
||||
// get latest warranty using plate number
|
||||
$warranty_results = $this->em->getRepository(Warranty::class)->findBy(
|
||||
['plate_number' => $plate_number],
|
||||
['date_create' => 'desc']
|
||||
);
|
||||
|
||||
$warr = [];
|
||||
|
||||
// check if warranty_results is empty
|
||||
if (empty($warranty_results)) {
|
||||
/*
|
||||
$res->setError(true)
|
||||
->setErrorMessage('No warranty found for plate number');
|
||||
return $res->getReturnResponse();
|
||||
*/
|
||||
|
||||
return $warr;
|
||||
}
|
||||
|
||||
// get first entry
|
||||
$warranty = current($warranty_results);
|
||||
|
||||
// check for null values for battery and date claim and date expire
|
||||
$batt_model = '';
|
||||
$batt_size = '';
|
||||
$sap_batt = '';
|
||||
$claim_date = '';
|
||||
$expiry_date = '';
|
||||
|
||||
if (!(is_null($warranty->getBatteryModel()))) {
|
||||
$batt_model = $warranty->getBatteryModel()->getName();
|
||||
}
|
||||
if (!(is_null($warranty->getBatterySize()))) {
|
||||
$batt_size = $warranty->getBatterySize()->getName();
|
||||
}
|
||||
if (!(is_null($warranty->getSAPBattery()))) {
|
||||
$sap_batt = $warranty->getSAPBattery()->getID();
|
||||
}
|
||||
if (!(is_null($warranty->getDateClaim()))) {
|
||||
$claim_date = $warranty->getDateClaim()->format("d M Y");
|
||||
}
|
||||
if (!(is_null($warranty->getDateExpire()))) {
|
||||
$expiry_date = $warranty->getDateExpire()->format("d M Y");
|
||||
}
|
||||
|
||||
$warr[] = [
|
||||
'id' => $warranty->getID(),
|
||||
'serial' => $warranty->getSerial(),
|
||||
'warranty_class' => $warranty->getWarrantyClass(),
|
||||
'plate_number' => $warranty->getPlateNumber(),
|
||||
'first_name' => $warranty->getFirstName(),
|
||||
'last_name' => $warranty->getLastName(),
|
||||
'mobile_number' => $warranty->getMobileNumber(),
|
||||
'battery_model' => $batt_model,
|
||||
'battery_size' => $batt_size,
|
||||
'sap_battery' => $sap_batt,
|
||||
'status' => $warranty->getStatus(),
|
||||
'date_create' => $warranty->getDateCreate()->format("d M Y g:i A"),
|
||||
'date_purchase' => $warranty->getDatePurchase()->format("d M Y"),
|
||||
'date_expire' => $expiry_date,
|
||||
'date_claim' => $claim_date,
|
||||
'claim_from' => $warranty->getClaimedFrom(),
|
||||
'is_activated' => $warranty->isActivated() ? 1 : 0,
|
||||
];
|
||||
|
||||
return $warr;
|
||||
}
|
||||
|
||||
protected function getBatteryImageURL($req, $batt)
|
||||
{
|
||||
// TODO: workaround for now, we get static image of battery based on model name
|
||||
$filename = trim(strtolower($batt->getModel()->getName())) . '_mobile.jpg';
|
||||
$filename = str_replace(" ", "_", $filename);
|
||||
$file_path = $req->getSchemeAndHttpHost() . $this->generateUrl('static_battery_image') . '/' . $filename;
|
||||
|
||||
return $file_path;
|
||||
}
|
||||
|
||||
protected function getOngoingJobOrders($cust)
|
||||
{
|
||||
$ongoing_jos = $this->em->getRepository(JobOrder::class)->findBy([
|
||||
'customer' => $cust,
|
||||
'status' => [JOStatus::PENDING, JOStatus::RIDER_ASSIGN, JOStatus::IN_TRANSIT, JOStatus::ASSIGNED, JOStatus::IN_PROGRESS],
|
||||
], ['date_schedule' => 'desc']);
|
||||
|
||||
return $ongoing_jos;
|
||||
}
|
||||
|
||||
protected function getGeoErrorMessage()
|
||||
{
|
||||
return 'Our services are currently limited to some areas in Metro Manila, Baguio, Batangas, Laguna, Cavite, Pampanga, and Palawan. We will update you as soon as we are available in your area. Thank you for understanding. Keep safe!';
|
||||
}
|
||||
}
|
||||
53
src/Controller/CustomerAppAPI/AppController.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CustomerAppAPI;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
||||
|
||||
class AppController extends ApiController
|
||||
{
|
||||
public function versionCheck(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$missing = $this->hasMissingParams($req, [
|
||||
'version',
|
||||
'os',
|
||||
]);
|
||||
|
||||
if ($missing) {
|
||||
return new ApiResponse(false, $missing);
|
||||
}
|
||||
|
||||
$need_update = false;
|
||||
$msg = 'Version is up to date.';
|
||||
|
||||
$os = $req->query->get('os');
|
||||
|
||||
// putting this in for the future, in case we have diverging versions
|
||||
//$platform = $req->query->get('platform');
|
||||
|
||||
// get only the major version numbers
|
||||
$app_version = $req->query->get('version');
|
||||
$app_major = substr($app_version, 0, strripos($app_version, "."));
|
||||
|
||||
$latest_version = $this->getParameter($os . '_app_version');
|
||||
$latest_major = substr($latest_version, 0, strripos($latest_version, "."));
|
||||
|
||||
if ($latest_major < $app_major) {
|
||||
return new ApiResponse(false, 'Invalid application version: ' . $app_version);
|
||||
}
|
||||
|
||||
if ($latest_major > $app_major) {
|
||||
$need_update = true;
|
||||
$msg = 'Your version is outdated and needs an update to use the latest features RES-Q has to offer.';
|
||||
}
|
||||
|
||||
// response
|
||||
return new ApiResponse(true, '', [
|
||||
'need_update' => $need_update,
|
||||
'latest_version' => $latest_version,
|
||||
'message' => $msg,
|
||||
]);
|
||||
}
|
||||
}
|
||||
292
src/Controller/CustomerAppAPI/AuthController.php
Normal file
|
|
@ -0,0 +1,292 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CustomerAppAPI;
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\CustomerUser;
|
||||
use App\Entity\CustomerSession;
|
||||
use App\Service\RisingTideGateway;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class AuthController extends ApiController
|
||||
{
|
||||
public function register(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$missing = $this->hasMissingParams($req, [
|
||||
'phone_model',
|
||||
'os_type',
|
||||
'os_version',
|
||||
'phone_id',
|
||||
]);
|
||||
|
||||
if ($missing) {
|
||||
return new ApiResponse(false, $missing);
|
||||
}
|
||||
|
||||
// retry until we get a unique id
|
||||
while (true) {
|
||||
try {
|
||||
// instantiate session
|
||||
$sess = new CustomerSession();
|
||||
$sess->setPhoneModel($req->request->get('phone_model'))
|
||||
->setOSType($req->request->get('os_type'))
|
||||
->setOSVersion($req->request->get('os_version'))
|
||||
->setPhoneID($req->request->get('phone_id'));
|
||||
|
||||
// reopen in case we get an exception
|
||||
if (!$this->em->isOpen()) {
|
||||
$this->em = $this->em->create(
|
||||
$this->em->getConnection(),
|
||||
$this->em->getConfiguration()
|
||||
);
|
||||
}
|
||||
|
||||
// save
|
||||
$this->em->persist($sess);
|
||||
$this->em->flush();
|
||||
} catch (DBALException $e) {
|
||||
error_log($e->getMessage());
|
||||
// delay one second and try again
|
||||
sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// return data
|
||||
return new ApiResponse(true, '', [
|
||||
'session_key' => $sess->getID(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function confirmNumber(RisingTideGateway $rt, Request $req, TranslatorInterface $translator)
|
||||
{
|
||||
// validate request
|
||||
$validity = $this->validateRequest($req, [
|
||||
'phone_number'
|
||||
]);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
// phone number
|
||||
$phone_number = $req->request->get('phone_number');
|
||||
|
||||
// get otp_mode from .env
|
||||
$otp_mode = $_ENV['OTP_MODE'];
|
||||
|
||||
// check for hardcoded phone number for app store testing
|
||||
$test_numbers = explode(",", $_ENV['TEST_PHONE_NUMBERS']);
|
||||
|
||||
if (in_array($phone_number, $test_numbers)) {
|
||||
$code = '123456';
|
||||
$this->session->setConfirmCode($code)
|
||||
->setPhoneNumber($phone_number);
|
||||
$this->em->flush();
|
||||
|
||||
return new ApiResponse();
|
||||
}
|
||||
|
||||
// check if otp_mode is test
|
||||
if ($otp_mode == 'test') {
|
||||
$code = '123456';
|
||||
$this->session->setConfirmCode($code)
|
||||
->setPhoneNumber($phone_number);
|
||||
$this->em->flush();
|
||||
|
||||
return new ApiResponse();
|
||||
}
|
||||
|
||||
// TODO: spam protection
|
||||
|
||||
// TODO: validate phone number
|
||||
|
||||
// generate code and save
|
||||
$code = $this->generateConfirmCode();
|
||||
$this->session->setConfirmCode($code)
|
||||
->setPhoneNumber($phone_number);
|
||||
$this->em->flush();
|
||||
|
||||
if ($otp_mode != 'test') {
|
||||
// send sms to number
|
||||
$this->sendConfirmationCode($rt, $phone_number, $code, $translator);
|
||||
}
|
||||
|
||||
// response
|
||||
return new ApiResponse();
|
||||
}
|
||||
|
||||
public function validateCode(Request $req)
|
||||
{
|
||||
// validate request
|
||||
$validity = $this->validateRequest($req, [
|
||||
'code',
|
||||
]);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
// already confirmed
|
||||
if ($this->session->isConfirmed()) {
|
||||
return new ApiResponse(false, 'User is already confirmed.');
|
||||
}
|
||||
|
||||
// code is wrong
|
||||
$code = $req->request->get('code');
|
||||
if ($this->session->getConfirmCode() != $code) {
|
||||
return new ApiResponse(false, 'Wrong confirm code.');
|
||||
}
|
||||
|
||||
// set confirm date
|
||||
$date = new DateTime();
|
||||
$this->session->setDateConfirmed($date)
|
||||
->setConfirmed();
|
||||
|
||||
// figure out if we have customer and customer user already
|
||||
$customer_user = false;
|
||||
|
||||
// TODO: check if we have the number registered before and merge
|
||||
$dupe_sess = $this->findNumberSession($this->session->getPhoneNumber());
|
||||
if ($dupe_sess != null) {
|
||||
error_log("Found existing customer session for " . $this->session->getPhoneNumber());
|
||||
$dupe_cust = $dupe_sess->getCustomer();
|
||||
$this->session->setCustomer($dupe_cust);
|
||||
|
||||
// set customer user if it exists
|
||||
$customer_user = $dupe_sess->getCustomerUser() ?? $dupe_cust->getCustomerUser();
|
||||
}
|
||||
|
||||
// TODO: check if mobile matches mobile of customer
|
||||
$customer = $this->findCustomerByNumber($this->session->getPhoneNumber());
|
||||
if ($customer != null) {
|
||||
// TODO: if there is a dupe_sess, do we need to check if
|
||||
// dupe_cust is the same as the customer we found?
|
||||
$this->session->setCustomer($customer);
|
||||
}
|
||||
|
||||
if (!$customer_user) {
|
||||
error_log("We don't have a customer user for session " . $this->session->getID());
|
||||
|
||||
$customer_user = $this->findCustomerUserByNumber($this->session->getPhoneNumber());
|
||||
|
||||
if ($customer_user === null) {
|
||||
error_log("Creating a new customer user for " . $this->session->getPhoneNumber());
|
||||
$customer_user = new CustomerUser();
|
||||
$customer_user->setCustomer($this->session->getCustomer())
|
||||
->setPhoneNumber($this->session->getPhoneNumber());
|
||||
|
||||
// save
|
||||
$this->em->persist($customer_user);
|
||||
$this->em->flush();
|
||||
} else {
|
||||
error_log("Found existing customer user for " . $this->session->getPhoneNumber());
|
||||
}
|
||||
}
|
||||
|
||||
error_log("Customer user ID is " . $customer_user->getID());
|
||||
|
||||
// set session customer user
|
||||
$this->session->setCustomerUser($customer_user);
|
||||
$this->em->flush();
|
||||
|
||||
// response
|
||||
return new ApiResponse(true, '', [
|
||||
'api_key' => $customer_user->getApiKey(),
|
||||
'secret_key'=> $customer_user->getSecretKey(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function resendCode(Request $req, RisingTideGateway $rt, TranslatorInterface $translator)
|
||||
{
|
||||
// validate request
|
||||
$validity = $this->validateRequest($req);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
// already confirmed
|
||||
if ($this->session->isConfirmed()) {
|
||||
return new ApiResponse(false, 'User is already confirmed.');
|
||||
}
|
||||
|
||||
// have sent code before
|
||||
if ($this->session->getDateCodeSent() != null) {
|
||||
return new ApiResponse(false, 'Can only send confirm code every 5 mins.');
|
||||
}
|
||||
|
||||
// TODO: send via sms
|
||||
$phone_number = $this->session->getPhoneNumber();
|
||||
$code = $this->session->getConfirmCode();
|
||||
$this->sendConfirmationCode($rt, $phone_number, $code, $translator);
|
||||
|
||||
// response
|
||||
return new ApiResponse();
|
||||
}
|
||||
|
||||
protected function generateConfirmCode()
|
||||
{
|
||||
return sprintf("%06d", mt_rand(100000, 999999));
|
||||
}
|
||||
|
||||
protected function sendConfirmationCode(RisingTideGateway $rt, $phone_number, $code, TranslatorInterface $translator)
|
||||
{
|
||||
// send sms to number
|
||||
$message = $translator->trans('message.confirmation_code') . ' ' . $code;
|
||||
$rt->sendSMS($phone_number, $translator->trans('message.battery_brand_allcaps'), $message);
|
||||
}
|
||||
|
||||
// TODO: find session customer by phone number
|
||||
protected function findNumberSession($number)
|
||||
{
|
||||
$query = $this->em->getRepository(CustomerSession::class)->createQueryBuilder('s')
|
||||
->where('s.phone_number = :number')
|
||||
->andWhere('s.customer is not null')
|
||||
->andWhere('s.customer_user is not null')
|
||||
->andWhere('s.confirm_flag = 1')
|
||||
->setParameter('number', $number)
|
||||
->setMaxResults(1)
|
||||
->getQuery();
|
||||
|
||||
// we just need one
|
||||
$res = $query->getOneOrNullResult();
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
protected function findCustomerByNumber($number)
|
||||
{
|
||||
$customers = $this->em->getRepository(Customer::class)->findBy(['phone_mobile' => $number]);
|
||||
|
||||
// find the customer with the most number of cars
|
||||
$car_count = 0;
|
||||
$cust = null;
|
||||
|
||||
foreach ($customers as $customer) {
|
||||
$vehicles = $customer->getVehicles();
|
||||
if (count($vehicles) > $car_count) {
|
||||
$car_count = count($vehicles);
|
||||
|
||||
// "save" customer object
|
||||
$cust = $customer;
|
||||
}
|
||||
}
|
||||
|
||||
return $cust;
|
||||
}
|
||||
|
||||
protected function findCustomerUserByNumber($number)
|
||||
{
|
||||
return $this->em->getRepository(CustomerUser::class)->findOneBy(['phone_number' => $number]);
|
||||
}
|
||||
}
|
||||
145
src/Controller/CustomerAppAPI/CustomerController.php
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CustomerAppAPI;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
||||
|
||||
use App\Ramcar\CustomerSource;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\PrivacyPolicy;
|
||||
use App\Service\HashGenerator;
|
||||
|
||||
class CustomerController extends ApiController
|
||||
{
|
||||
public function getInfo(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
// if no customer found
|
||||
$cust = $this->session->getCustomer();
|
||||
if ($cust == null) {
|
||||
return new ApiResponse(true, '', [
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'priv_third_party' => (bool) false,
|
||||
'priv_promo' => (bool) false,
|
||||
]);
|
||||
}
|
||||
|
||||
// send back customer details
|
||||
return new ApiResponse(true, '', [
|
||||
'first_name' => $cust->getFirstName(),
|
||||
'last_name' => $cust->getLastName(),
|
||||
'priv_third_party' => (bool) $cust->getPrivacyThirdParty(),
|
||||
'priv_promo' => (bool) $cust->getPrivacyPromo(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateInfo(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req, [
|
||||
'first_name',
|
||||
'last_name',
|
||||
]);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
$cust = $this->updateCustomerInfo($req);
|
||||
|
||||
$policy_mobile_id = $_ENV['POLICY_MOBILE'];
|
||||
$mobile_policy = $this->em->getRepository(PrivacyPolicy::class)->find($policy_mobile_id);
|
||||
|
||||
// set policy id
|
||||
if ($mobile_policy != null) {
|
||||
$cust->setPrivacyPolicyMobile($mobile_policy);
|
||||
}
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
// response
|
||||
return new ApiResponse();
|
||||
}
|
||||
|
||||
public function getStatus(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
// set data
|
||||
$data = [];
|
||||
if ($this->session->isConfirmed()) {
|
||||
$data['status'] = 'confirmed';
|
||||
} else {
|
||||
$data['status'] = 'unconfirmed';
|
||||
}
|
||||
|
||||
return new ApiResponse(true, '', $data);
|
||||
}
|
||||
|
||||
public function getCustomerHash(Request $req, HashGenerator $hash)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
// get customer
|
||||
$cust = $this->session->getCustomer();
|
||||
if ($cust == null) {
|
||||
return new ApiResponse(false, 'No customer information found.');
|
||||
}
|
||||
|
||||
// hash customer id
|
||||
$hashed_id = $hash->getHash($cust->getID());
|
||||
|
||||
// response
|
||||
return new ApiResponse(true, '', [
|
||||
'cust_hash' => $hashed_id,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function updateCustomerInfo(Request $req)
|
||||
{
|
||||
// create new customer if it's not there
|
||||
$cust = $this->session->getCustomer();
|
||||
if ($cust == null) {
|
||||
$cust = new Customer();
|
||||
|
||||
// set customer source
|
||||
$cust->setCreateSource(CustomerSource::MOBILE);
|
||||
$this->em->persist($cust);
|
||||
|
||||
$this->session->setCustomer($cust);
|
||||
}
|
||||
|
||||
$cust->setFirstName($req->request->get('first_name'))
|
||||
->setLastName($req->request->get('last_name'))
|
||||
->setEmail($req->request->get('email', ''))
|
||||
->setConfirmed($this->session->isConfirmed());
|
||||
|
||||
// if customer user isn't set, set it now
|
||||
if ($cust->getCustomerUser() == null) {
|
||||
$cust->setCustomerUser($this->session->getCustomerUser());
|
||||
}
|
||||
|
||||
// update mobile phone of customer
|
||||
$cust->setPhoneMobile($this->session->getPhoneNumber());
|
||||
|
||||
return $cust;
|
||||
}
|
||||
}
|
||||
29
src/Controller/CustomerAppAPI/DeviceController.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CustomerAppAPI;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
||||
|
||||
class DeviceController extends ApiController
|
||||
{
|
||||
public function updateDeviceID(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req, [
|
||||
'device_id',
|
||||
]);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
$device_id = $req->request->get('device_id');
|
||||
$this->session->setDevicePushID($device_id);
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
// response
|
||||
return new ApiResponse();
|
||||
}
|
||||
}
|
||||
364
src/Controller/CustomerAppAPI/InsuranceController.php
Normal file
|
|
@ -0,0 +1,364 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller\CustomerAppAPI;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Catalyst\ApiBundle\Component\Response as ApiResponse;
|
||||
|
||||
use App\Service\InsuranceConnector;
|
||||
use App\Service\PayMongoConnector;
|
||||
|
||||
use App\Entity\InsuranceApplication;
|
||||
use App\Entity\GatewayTransaction;
|
||||
use App\Entity\CustomerVehicle;
|
||||
|
||||
use App\Ramcar\InsuranceApplicationStatus;
|
||||
use App\Ramcar\InsuranceMVType;
|
||||
use App\Ramcar\InsuranceClientType;
|
||||
use App\Ramcar\TransactionStatus;
|
||||
use App\Ramcar\InsuranceBodyType;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class InsuranceController extends ApiController
|
||||
{
|
||||
protected $client;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, KernelInterface $kernel, InsuranceConnector $client)
|
||||
{
|
||||
parent::__construct($em, $kernel);
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
public function createApplication(Request $req, PayMongoConnector $paymongo, UrlGeneratorInterface $router)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req, [
|
||||
// internal
|
||||
'customer_vehicle_id',
|
||||
|
||||
// client info
|
||||
'client_type',
|
||||
'first_name',
|
||||
//'middle_name', // not required
|
||||
'surname',
|
||||
'corporate_name',
|
||||
|
||||
// client contact info
|
||||
'address_number',
|
||||
//'address_street', // not required
|
||||
//'address_building', // not required
|
||||
'address_barangay',
|
||||
'address_city',
|
||||
'address_province',
|
||||
'zipcode',
|
||||
'mobile_number',
|
||||
'email_address',
|
||||
|
||||
// car info
|
||||
'make',
|
||||
'model',
|
||||
'series',
|
||||
'color',
|
||||
//'plate_number', // NOTE: we get this from the internal cv record instead
|
||||
'mv_file_number',
|
||||
'motor_number',
|
||||
'serial_chasis', // NOTE: this is how it's spelled on their API
|
||||
'year_model',
|
||||
'mv_type_id',
|
||||
'body_type',
|
||||
//'is_public', // not required, boolean, only show field if mv_type_id in [4, 13]
|
||||
//'orcr_file', // this is a file
|
||||
|
||||
// mv_type_id specific fields
|
||||
//'vehicle_use_type', // not required, only show field if mv_type_id is not in [4, 13]. accepted values are: 'commercial', 'private'
|
||||
]);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
// conditionally require is_public or vehicle_use_type
|
||||
switch ($req->request->get('mv_type_id')) {
|
||||
case 4:
|
||||
case 13:
|
||||
if (empty($req->request->get('is_public'))) {
|
||||
return new ApiResponse(false, 'Missing required parameter(s): is_public is required when mv_type_id is in [4, 13]');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (empty($req->request->get('vehicle_use_type'))) {
|
||||
return new ApiResponse(false, 'Missing required parameter(s): vehicle_use_type is required when mv_type_id is not in [4, 13]');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// require the orcr file
|
||||
if ($req->files->get('orcr_file') === null) {
|
||||
return new ApiResponse(false, 'Missing required file: orcr_file');
|
||||
}
|
||||
|
||||
// get our listener url
|
||||
$notif_url = $router->generate('insurance_listener', [], UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
|
||||
// get customer and cv info
|
||||
$cust = $this->session->getCustomer();
|
||||
$cv = $this->em->getRepository(CustomerVehicle::class)->find($req->request->get('customer_vehicle_id'));
|
||||
if ($cv == null) {
|
||||
return new ApiResponse(false, 'Invalid customer vehicle id.');
|
||||
}
|
||||
|
||||
// confirm that customer vehicle belongs to customer
|
||||
if ($cv->getCustomer()->getID() != $cust->getID()) {
|
||||
return new ApiResponse(false, 'Vehicle does not belong to customer.');
|
||||
}
|
||||
|
||||
// process all our inputs first
|
||||
$input = $req->request->all();
|
||||
|
||||
if (!isset($input['is_public'])) {
|
||||
$input['is_public'] = false;
|
||||
}
|
||||
|
||||
$input['line'] = $this->getLineType($input['mv_type_id'], $input['vehicle_use_type'], $input['is_public']);
|
||||
|
||||
// submit insurance application
|
||||
$result = $this->client->createApplication(
|
||||
$cv,
|
||||
$notif_url,
|
||||
$input,
|
||||
$req->files->get('orcr_file')
|
||||
);
|
||||
if (!$result['success']) {
|
||||
return new ApiResponse(false, $result['error']['message']);
|
||||
}
|
||||
|
||||
$premium_amount_int = (int)bcmul($result['response']['premium'], 100);
|
||||
|
||||
// build checkout item and metadata
|
||||
$items = [
|
||||
[
|
||||
'name' => "Insurance Premium",
|
||||
'description' => "Premium fee for vehicle insurance",
|
||||
'quantity' => 1,
|
||||
'amount' => $premium_amount_int,
|
||||
'currency' => 'PHP',
|
||||
],
|
||||
];
|
||||
|
||||
$now = new DateTime();
|
||||
|
||||
// create gateway transaction
|
||||
$gt = new GatewayTransaction();
|
||||
$gt->setCustomer($cust);
|
||||
$gt->setDateCreate($now);
|
||||
$gt->setAmount($premium_amount_int);
|
||||
$gt->setStatus(TransactionStatus::PENDING);
|
||||
$gt->setGateway('paymongo'); // TODO: define values elsewhere
|
||||
$gt->setType('insurance_premium'); // TODO: define values elsewhere
|
||||
$this->em->persist($gt);
|
||||
$this->em->flush();
|
||||
|
||||
// create paymongo checkout resource
|
||||
$checkout = $paymongo->createCheckout(
|
||||
$cust,
|
||||
$items,
|
||||
$gt->getID(),
|
||||
"Motolite RES-Q Vehicle Insurance",
|
||||
$router->generate('paymongo_payment_success', [], UrlGeneratorInterface::ABSOLUTE_URL),
|
||||
$router->generate('paymongo_payment_cancelled', [], UrlGeneratorInterface::ABSOLUTE_URL),
|
||||
['transaction_id' => $gt->getID()], // NOTE: passing this here too for payment resource metadata
|
||||
);
|
||||
if (!$checkout['success']) {
|
||||
return new ApiResponse(false, $checkout['error']['message']);
|
||||
}
|
||||
|
||||
$checkout_url = $checkout['response']['data']['attributes']['checkout_url'];
|
||||
|
||||
// add checkout url and id to transaction metadata
|
||||
$gt->setExtTransactionId($checkout['response']['data']['id']);
|
||||
$gt->setMetadata([
|
||||
'checkout_url' => $checkout_url,
|
||||
]);
|
||||
|
||||
// store application in db
|
||||
$app = new InsuranceApplication();
|
||||
$app->setDateSubmit($now);
|
||||
$app->setCustomer($cust);
|
||||
$app->setCustomerVehicle($cv);
|
||||
$app->setGatewayTransaction($gt);
|
||||
$app->setStatus(InsuranceApplicationStatus::CREATED);
|
||||
$app->setExtTransactionId($result['response']['id']);
|
||||
$app->setMetadata($input);
|
||||
$this->em->persist($app);
|
||||
|
||||
// save everything
|
||||
$this->em->flush();
|
||||
|
||||
// return
|
||||
return new ApiResponse(true, '', [
|
||||
'app_id' => $app->getID(),
|
||||
'checkout_url' => $checkout_url,
|
||||
'premium_amount' => (string)$result['response']['premium'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function getVehicleMakers(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
// get maker list
|
||||
$result = $this->client->getVehicleMakers();
|
||||
if (!$result['success']) {
|
||||
return new ApiResponse(false, $result['error']['message']);
|
||||
}
|
||||
|
||||
return new ApiResponse(true, '', [
|
||||
'makers' => $result['response']['data']['vehicleMakers'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function getVehicleModels($maker_id, Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
// get maker list
|
||||
$result = $this->client->getVehicleModels($maker_id);
|
||||
if (!$result['success']) {
|
||||
return new ApiResponse(false, $result['error']['message']);
|
||||
}
|
||||
|
||||
return new ApiResponse(true, '', [
|
||||
'models' => $result['response']['data']['vehicleModels'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function getVehicleTrims($model_id, Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
// get maker list
|
||||
$result = $this->client->getVehicleTrims($model_id);
|
||||
if (!$result['success']) {
|
||||
return new ApiResponse(false, $result['error']['message']);
|
||||
}
|
||||
|
||||
return new ApiResponse(true, '', [
|
||||
'trims' => $result['response']['data']['vehicleTrims'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function getMVTypes(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
return new ApiResponse(true, '', [
|
||||
'mv_types' => InsuranceMVType::getCollection(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function getClientTypes(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
return new ApiResponse(true, '', [
|
||||
'mv_types' => InsuranceClientType::getCollection(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function getPremiumsBanner(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
return new ApiResponse(true, '', [
|
||||
'url' => $this->getParameter('insurance_premiums_banner_url'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function getBodyTypes(Request $req)
|
||||
{
|
||||
// validate params
|
||||
$validity = $this->validateRequest($req);
|
||||
|
||||
if (!$validity['is_valid']) {
|
||||
return new ApiResponse(false, $validity['error']);
|
||||
}
|
||||
|
||||
$bt_collection = InsuranceBodyType::getCollection();
|
||||
$body_types = [];
|
||||
|
||||
// NOTE: formatting it this way to match how insurance third party API returns their own stuff, so it's all handled one way on the app
|
||||
foreach ($bt_collection as $bt_key => $bt_name) {
|
||||
$body_types[] = [
|
||||
'id' => $bt_key,
|
||||
'name' => $bt_name,
|
||||
];
|
||||
}
|
||||
|
||||
return new ApiResponse(true, '', [
|
||||
'body_types' => $body_types,
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getLineType($mv_type_id, $vehicle_use_type, $is_public = false)
|
||||
{
|
||||
$line = '';
|
||||
|
||||
// NOTE: this is a bit of a hack since we're hardcoding values, but this is fine for now
|
||||
switch ($mv_type_id) {
|
||||
case '3':
|
||||
$line = 'mcoc';
|
||||
break;
|
||||
case '4':
|
||||
case '13':
|
||||
if ($is_public) {
|
||||
$line = 'lcoc';
|
||||
} else {
|
||||
$line = 'mcoc';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if ($vehicle_use_type === 'commercial') {
|
||||
$line = 'ccoc';
|
||||
} else {
|
||||
$line = 'pcoc';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $line;
|
||||
}
|
||||
}
|
||||