Compare commits

...
Sign in to create a new pull request.

375 commits

Author SHA1 Message Date
K Muller
5634d4d232 Merge branch 'trunk' 2026-10-15 09:12:44 +02:00
K Muller
9a1a07307b Merge branch 'develop' into trunk 2026-10-15 09:12:16 +02:00
Karl M'muller
8410447a29 Merge branch '134-restore-soft-delete' into 'develop'
feat: ✨ restore soft-deleted user on create

See merge request ldc-web/projets/support-web!138
2026-10-15 07:11:08 +00:00
Corentin Huet
f0fb7a26f3 feat: ✨ restore soft-deleted user on create 2026-10-08 15:31:11 +02:00
Noah Lancien
f55ca959b8 Merge branch 'trunk' 2026-10-07 15:30:35 +02:00
Noah Lancien
d622f543e9 Merge branch 'develop' into trunk 2026-10-07 15:29:51 +02:00
Noix
1f1c684008 Merge branch '133-export-file' into 'develop'
feat: ✨ change ExportTicketsState to Friday 14:00

See merge request ldc-web/projets/support-web!137
2026-10-07 13:20:45 +00:00
Corentin Huet
e8c5472d45 feat: ✨ change ExportTicketsState to Friday 14:00 2026-10-07 09:30:01 +02:00
Noah Lancien
4ff19d9277 Merge branch 'trunk' 2026-10-01 10:07:26 +02:00
Noah Lancien
7dfd80cf23 Merge branch 'develop' into trunk 2026-10-01 10:07:12 +02:00
Noix
e19d810a2f Merge branch '132-create-gitlab-issue' into 'develop'
feat: ✨ allow creating gitlab issues for mailing type

See merge request ldc-web/projets/support-web!136
2026-10-01 08:06:30 +00:00
Corentin Huet
ab998c975d feat: ✨ allow creating gitlab issues for mailing type 2026-09-01 16:51:04 +02:00
Vincent BRIDIER
9706922312 Merge branch 'trunk' 2026-08-27 20:56:21 +02:00
Vincent BRIDIER
ebb52b5968 Merge branch 'develop' into trunk 2026-08-27 20:56:07 +02:00
Vincent BRIDIER
6c783247a7 fix: Alpine www-data = 82 2026-08-27 20:54:40 +02:00
K Muller
6cf790feab Merge branch 'trunk' 2026-08-26 12:58:54 +02:00
K Muller
57c7613455 Merge branch 'develop' into trunk 2026-08-26 12:58:41 +02:00
Karl M'muller
eddeb4f7f6 Merge branch '128-archived-project' into 'develop'
fix: 🐛 add error message for archived project

See merge request ldc-web/projets/support-web!135
2026-08-26 10:58:10 +00:00
Karl M'muller
d9d1fea624 Merge branch '127-error-sentry' into 'develop'
fix: 🐛 update regex to match both issue and work items

See merge request ldc-web/projets/support-web!134
2026-08-26 10:57:57 +00:00
Corentin Huet
22d79cfb11 fix: 🐛 add error message for archived project 2026-08-25 13:16:11 +02:00
Corentin Huet
22bc49baab fix: 🐛 update regex to match both issue and work items 2026-08-24 17:50:16 +02:00
K Muller
adb2a8b21c Merge branch 'trunk' 2026-07-23 09:26:12 +02:00
K Muller
7246d7894d Merge branch 'develop' into trunk 2026-07-23 09:25:13 +02:00
Karl M'muller
10b75031e7 Merge branch 'issue-126' into 'develop'
Fix: 🐛 duplicate emails sent when a ticket's modif is changed

See merge request ldc-web/projets/support-web!133
2026-07-23 07:23:38 +00:00
Abdel LAMRANI
68a48fdf5a Fix: 🐛 duplicate emails sent when a ticket's modif is changed 2026-07-20 12:45:46 +02:00
Jeremy Munsch
a7debacd65
Merge branch 'trunk' 2026-06-26 15:36:53 +02:00
Jeremy Munsch
dd10d4ba3a
Merge branch 'develop' into trunk 2026-06-26 15:36:43 +02:00
Jeremy Munsch
a7bd6d6420
fixed: NotifyAdmin event listener 2026-06-26 15:36:34 +02:00
Jeremy Munsch
8cfc409d5c
Merge branch 'trunk' 2026-06-26 15:28:54 +02:00
Jeremy Munsch
bc7a1020bc
Merge branch 'develop' into trunk 2026-06-26 15:28:45 +02:00
Jeremy Munsch
e828c8bf66
fix: TicketCreated event 2026-06-26 15:28:31 +02:00
Jeremy Munsch
f28dbdd1df
Merge branch 'trunk' 2026-06-26 15:15:10 +02:00
Jeremy Munsch
965226fae6
Fixed ticket creation 2026-06-26 15:14:32 +02:00
Jeremy Munsch
bd9b7cd32e
fix: new ticket creation failed 2026-06-26 15:13:48 +02:00
Noah Lancien
8c67989526 Merge branch 'trunk' 2026-06-26 09:50:56 +02:00
Noah Lancien
2212b0ae08 Merge branch 'develop' into trunk 2026-06-26 09:50:41 +02:00
Noix
c2b25c3503 Merge branch 'brevo-fix' into 'develop'
fix: brevo in (content commit that were missed)

See merge request ldc-web/projets/support-web!132
2026-06-26 07:46:25 +00:00
Jeremy Munsch
f106c17588
fix: brevo in (content commit that were missed) 2026-06-26 09:33:50 +02:00
Noah Lancien
8e9d117918 Merge branch 'trunk' 2026-06-25 11:07:30 +02:00
Noah Lancien
0dbb483fc4 Merge branch 'develop' into trunk 2026-06-25 08:47:02 +02:00
Noah Lancien
980717f37c ci: swicth to docker multi-stage 2026-06-25 08:46:44 +02:00
Noah Lancien
020fcdaa03 Merge branch 'develop' into trunk 2026-06-25 08:37:04 +02:00
Noix
095f80eac1 Merge branch 'brevo-webhook-fix' into 'develop'
Brevo webhook fix Closes #106

See merge request ldc-web/projets/support-web!130
2026-06-25 06:36:32 +00:00
Noix
6a973703c4 Merge branch 'issue-124' into 'develop'
refactor: change ldc logo Closes #124

See merge request ldc-web/projets/support-web!131
2026-06-25 06:36:22 +00:00
Jeremy Munsch
9a853088b1
refactor: change ldc logo Closes #124 2026-06-24 17:22:58 +02:00
Jeremy Munsch
0ec3be521d
refactor: Fixes #106 create ticket automatically from brevo webhook manager 2026-06-24 16:46:12 +02:00
Jeremy Munsch
6854af708b
fix: fix project migrations 2026-06-24 13:22:36 +02:00
Noah Lancien
8f1c920e26 Merge branch 'trunk' 2026-05-18 10:28:44 +02:00
Noah Lancien
efe5e8ace6 Merge branch 'develop' into trunk 2026-05-18 10:28:29 +02:00
Noah Lancien
91f4773c60 chore: 📦 Added meow npm package 2026-05-18 10:28:21 +02:00
Noah Lancien
6b5b4ec619 Merge branch 'trunk' 2026-05-18 10:18:39 +02:00
Noah Lancien
4edd92e572 Merge branch 'develop' into trunk 2026-05-18 10:18:20 +02:00
Noix
da03fbe273 Merge branch '115-project-not-found' into 'develop'
fix: 🐛 handle 404 when gitlab project is not found

See merge request ldc-web/projets/support-web!128
2026-05-18 08:12:44 +00:00
Noah Lancien
b7f7b7c55d Merge branch 'trunk' 2026-04-29 16:28:13 +02:00
Noah Lancien
49d37a8fa6 Merge branch 'develop' into trunk 2026-04-29 16:18:44 +02:00
Noah Lancien
195a5fcb3e chore: arrow_up: Bump PHP 8.5 2026-04-29 16:18:25 +02:00
Noah Lancien
e0af4a243a Merge branch 'trunk' 2026-04-29 16:10:44 +02:00
Noah Lancien
0c4d376c22 Merge branch 'develop' into trunk 2026-04-29 16:10:11 +02:00
Noix
6fabb998ed Merge branch 'support-to-glab-labels' into 'develop'
fix: 🐛 update to-dispatch label to g-to-dispatch

See merge request ldc-web/projets/support-web!129
2026-04-29 14:09:36 +00:00
Corentin Huet
04bd156849 fix: 🐛 update to-dispatch label to g-to-dispatch 2026-04-28 15:16:20 +02:00
Corentin Huet
a43037d2f9 fix: 🐛 handle 404 when gitlab project is not found 2026-03-30 11:59:42 +02:00
Noah Lancien
ef57fe9fe5 Merge branch 'trunk' 2026-03-25 11:52:33 +01:00
Noah Lancien
62901a015e Merge branch 'develop' into trunk 2026-03-25 11:52:18 +01:00
noah.lancien
004af70c30 Merge branch '107-issue-bug' into 'develop'
fix: 🐛 remove duplicate imports

See merge request ldc-web/projets/support-web!127
2026-03-25 10:51:55 +00:00
noah.lancien
c88f3e8d52 Merge branch '90-invoice-filters' into 'develop'
feat: ✨ add awaiting signature/invoicing filters and auto-set...

See merge request ldc-web/projets/support-web!121
2026-03-25 10:48:36 +00:00
Corentin Huet
fb78d5a77d fix: 🐛 remove duplicate imports 2026-03-25 11:48:29 +01:00
noah.lancien
292456bf14 Merge branch '107-issue-bug' into 'develop'
feat: ✨ add to-dispatch label for bug tickets and change default assignee label

See merge request ldc-web/projets/support-web!120
2026-03-25 10:48:12 +00:00
Corentin Huet
a43c6c95b1 feat: ✨ add to-dispatch label for bug tickets and change default assignee label 2026-03-25 11:44:17 +01:00
noah.lancien
9b2248b146 Merge branch '111-add-column' into 'develop'
feat: ✨ add estimate column to tickets page

See merge request ldc-web/projets/support-web!126
2026-03-24 15:49:59 +00:00
noah.lancien
9ea4786aa8 Merge branch '105-sync-gitlab-support' into 'develop'
Resolve "Liaison labels (Gitlab) et statuts (support tickets)"

See merge request ldc-web/projets/support-web!123
2026-03-24 15:48:12 +00:00
noah.lancien
b77c0908f6 Merge branch '87-ticket-status' into 'develop'
feat: ✨ add new status + sync of g-wip label with in development

See merge request ldc-web/projets/support-web!122
2026-03-24 15:47:40 +00:00
Corentin Huet
721e2200f6 feat: ✨ add estimate column to tickets page 2026-03-13 14:44:36 +01:00
Noah Lancien
cbabb40f83 Merge branch 'develop' into trunk 2026-02-26 12:10:44 +01:00
noah.lancien
e71c0546c5 Merge branch '112-feedback' into 'develop'
fix: 🐛 correct default selected status in filter dropdown

See merge request ldc-web/projets/support-web!125
2026-02-26 11:10:02 +00:00
Corentin Huet
ebeccffac6 fix: 🐛 correct default selected status in filter dropdown 2026-02-26 11:59:21 +01:00
Noah Lancien
870986faa4 Merge branch 'develop' into trunk 2026-02-26 11:15:14 +01:00
noah.lancien
da65fcd12c Merge branch '112-unused-packages' into 'develop'
feat: ✨ add published status filter to packages listing

See merge request ldc-web/projets/support-web!124
2026-02-26 10:14:38 +00:00
Corentin Huet
e0e6147576 feat: ✨ add published status filter to packages listing 2026-02-26 10:20:22 +01:00
Corentin Huet
c7493abea0 feat: ✨ sync support statuses with gitlab 2026-02-11 13:34:43 +01:00
Corentin Huet
95b69e9496 feat: ✨ add new status + sync of g-wip label with in development 2026-02-11 13:21:29 +01:00
Corentin Huet
a3123a2bf2 feat: ✨ add awaiting signature/invoicing filters and auto-set archived status on accounting sent date 2026-02-09 09:39:24 +01:00
Noah Lancien
33ea75a5ed Merge branch 'trunk' 2026-01-29 12:38:38 +01:00
Noah Lancien
3e09baf6f3 Merge branch 'develop' into trunk 2026-01-29 12:38:20 +01:00
Noah Lancien
1794076c91 ci: limit jobs history to 1 2026-01-29 12:38:01 +01:00
Noah Lancien
d5f1891764 Merge branch 'trunk' 2026-01-19 09:39:57 +01:00
Noah Lancien
098e40576e Merge branch 'develop' into trunk 2026-01-19 09:39:06 +01:00
noah.lancien
3b93ec45c9 Merge branch 'fix-sentry-error' into 'develop'
fix: 🐛 add null checks for webhook fields

See merge request ldc-web/projets/support-web!119
2026-01-19 08:36:56 +00:00
Corentin Huet
3b7ca55d73 fix: 🐛 add null checks for webhook fields 2026-01-16 17:20:25 +01:00
Noah Lancien
18b66793a0 Merge branch 'trunk' 2026-01-16 15:56:26 +01:00
Noah Lancien
7ee8a2be82 Merge branch 'develop' into trunk 2026-01-16 15:51:31 +01:00
noah.lancien
7e9cba3d2a Merge branch '106-mailing-ticket' into 'develop'
feat: ✨ implement webhook ticket creation with regex extraction

See merge request ldc-web/projets/support-web!118
2026-01-16 14:48:57 +00:00
Corentin Huet
4e275c3b37 feat: ✨ implement webhook ticket creation with regex extraction 2026-01-16 15:21:48 +01:00
Noah Lancien
87cc2dec86 Merge branch 'trunk' 2026-01-12 09:32:52 +01:00
Noah Lancien
ea41e19724 Merge branch 'develop' into trunk 2026-01-12 09:32:32 +01:00
Noah Lancien
37beca9c5e ci: added ci variables to define pod resources 2026-01-12 09:31:48 +01:00
Noah Lancien
7aa279e9e4 feat: updated admin-secure 2026-01-12 09:26:03 +01:00
Vincent BRIDIER
65772aeb1d Merge branch 'trunk' 2026-01-02 15:31:49 +01:00
Vincent BRIDIER
ea6ac998d8 Merge branch 'develop' into trunk 2026-01-02 15:31:35 +01:00
Vincent BRIDIER
b14305553f fix: Some PHPCBF 2026-01-02 15:31:21 +01:00
Vincent BRIDIER
aa9483a155 feat: Add Gitlab some datas sync 2026-01-02 15:30:52 +01:00
Noah Lancien
9bc3d9e5e0 Merge branch 'trunk' 2025-11-28 09:33:55 +01:00
Noah Lancien
f99dac8aab Merge branch 'develop' into trunk 2025-11-21 09:07:52 +01:00
noah.lancien
90f27bf560 Merge branch 'reorder-priority-fix' into 'develop'
fix: reorder tickets priority when one is archived

See merge request ldc-web/projets/support-web!117
2025-11-21 07:59:18 +00:00
Noah Lancien
ccc4ed596a fix: reorder tickets priority when one is archived 2025-11-20 17:04:08 +01:00
Noah Lancien
3f4342f3bb Merge branch 'develop' into trunk 2025-11-20 15:54:16 +01:00
noah.lancien
e67e4b3cef Merge branch '103-priority' into 'develop'
feat: replaced change-order with a new priority system

See merge request ldc-web/projets/support-web!116
2025-11-20 14:51:51 +00:00
Noah Lancien
c09214f59a fix: use increment/decrement instead of loop 2025-11-20 09:55:38 +01:00
Noah Lancien
950b2babdc feat: replaced change-order with a new priority system 2025-11-19 17:45:29 +01:00
Noah Lancien
481c732f3e Merge branch 'trunk' 2025-10-30 12:32:32 +01:00
Noah Lancien
887837dcaf Merge branch 'develop' into trunk 2025-10-30 12:22:06 +01:00
noah.lancien
13cc9d1394 Merge branch '102-fix-title' into 'develop'
fix: remove title field

See merge request ldc-web/projets/support-web!115
2025-10-30 11:19:07 +00:00
Corentin Huet
b97f7f575e fix: remove title field 2025-10-23 12:00:50 +02:00
K Muller
4bdcf60dfa Merge branch 'develop' into trunk 2025-10-23 10:32:31 +02:00
karl.muller
17ee6de791 Merge branch '101-mailing' into 'develop'
feat: ✨ add new ticket type for mass email requests

See merge request ldc-web/projets/support-web!113
2025-10-23 08:30:36 +00:00
karl.muller
460029cf83 Merge branch '102-ticket-name' into 'develop'
feat: ✨ add ticket title to tickets.show

See merge request ldc-web/projets/support-web!114
2025-10-23 08:30:32 +00:00
Corentin Huet
e54c491c2d feat: ✨ add ticket title to tickets.show 2025-10-21 11:33:43 +02:00
Corentin Huet
51f77d3be8 feat: ✨ add new ticket type for mass email requests 2025-10-21 11:15:54 +02:00
Noah Lancien
435d5626ee Merge branch 'trunk' 2025-10-09 11:50:24 +02:00
Noah Lancien
50ba8eaf8a Merge branch 'develop' into trunk 2025-10-09 11:50:12 +02:00
Noah Lancien
365b839f53 ci: added staging-resources.yaml 2025-10-09 11:49:53 +02:00
Noah Lancien
f2a65c85b0 Merge branch 'trunk' 2025-10-09 11:43:15 +02:00
Noah Lancien
1a2fe21212 Merge branch 'develop' into trunk 2025-10-09 11:42:45 +02:00
noah.lancien
4434538cc3 Merge branch 'issue-99' into 'develop'
fix: add automatic retries on deadlocks

See merge request ldc-web/projets/support-web!111
2025-10-09 09:38:21 +00:00
Noah Lancien
d702c02bdb Merge branch 'trunk' 2025-09-18 08:59:45 +02:00
Noah Lancien
b1a6dfb72c Merge branch 'develop' into trunk 2025-09-18 08:58:20 +02:00
noah.lancien
ec62c6d4b5 Merge branch 'issue-98' into 'develop'
feat: add ticket title in mails

See merge request ldc-web/projets/support-web!112
2025-09-18 06:56:43 +00:00
Corentin Huet
0f31e03169 feat: add ticket title in mails 2025-09-16 15:06:12 +02:00
Corentin Huet
849420f966 fix: add automatic retries on deadlocks 2025-09-16 12:19:48 +02:00
Vincent BRIDIER
844928e945 Merge branch 'trunk' 2025-08-22 12:51:32 +02:00
Vincent BRIDIER
3560e6c7f6 Merge branch 'develop' into trunk 2025-08-22 10:28:08 +02:00
Vincent BRIDIER
cc339201f0 Merge branch 'issue-84' into 'develop'
fix: 🐛 add another condition to test if the user subscribe to the ticket in Message.php

See merge request ldc-web/projets/support-web!109
2025-08-22 08:27:05 +00:00
nicolas.demangeat
e47d9a75e6 fix: 🐛 Change relationship management for subscriptions - Close #84 2025-08-22 08:27:05 +00:00
Vincent BRIDIER
4d777f6281 feat: Remove unique for gitlab_id on site - Close #94 2025-08-21 12:41:06 +02:00
Vincent BRIDIER
a3529361b7 Merge branch 'issue-95' into 'develop'
fix: 🚑 add Null coalescing operator in projects index.blade to avoid production error

See merge request ldc-web/projets/support-web!110
2025-08-21 10:28:32 +00:00
Vincent BRIDIER
93a4d54a9e feat: Remove legacy Projects parts 2025-08-21 12:24:42 +02:00
Vincent BRIDIER
46bfa5ef1f feat: Update readme 2025-08-20 14:46:50 +00:00
Nicolas Demangeat
005378de41 fix: 🐛 add cascadeOnDelete to project table and change the Project query in index method in ProjectController 2025-08-19 10:27:36 +02:00
Nicolas Demangeat
ed4b227f9a fix: 🚑 add Null coalescing operator in projects index.blade to avoid production error 2025-08-18 15:29:44 +02:00
Vincent BRIDIER
aa3f507483
Merge branch 'trunk' 2025-08-18 14:16:25 +02:00
Vincent BRIDIER
8a34a30ab4
Merge branch 'develop' into trunk 2025-08-18 14:16:17 +02:00
Vincent BRIDIER
88abac9a5d
fix: Fix Requests 2025-08-18 14:16:06 +02:00
Vincent BRIDIER
9172d75e5d
fix: Fix Requests 2025-08-18 14:15:04 +02:00
Vincent BRIDIER
4a0c556937
Merge branch 'trunk' 2025-08-18 14:03:06 +02:00
Vincent BRIDIER
085028a465
Merge branch 'develop' into trunk 2025-08-18 12:40:48 +02:00
Vincent BRIDIER
21abe7d761
fix: Fix Requests 2025-08-18 12:40:36 +02:00
Vincent BRIDIER
f9ed83ff60
Merge branch 'develop' into trunk 2025-08-18 12:13:24 +02:00
Vincent BRIDIER
df912545e1
feat: Add words blacklist for message and ticket creation 2025-08-18 12:13:04 +02:00
Noah Lancien
1ffb5e5bdd Merge branch 'trunk' 2025-07-10 14:54:56 +02:00
Noah Lancien
c6fcd7cfa6 Merge branch 'develop' into trunk 2025-07-10 13:05:54 +02:00
noah.lancien
8f0a139663 Merge branch 'issue-71-favourite' into 'develop'
feat: choice of favourite site added to settings

See merge request ldc-web/projets/support-web!108
2025-07-10 11:04:02 +00:00
Corentin Huet
7ee190f1d3 feat: choice of favourite site added to settings 2025-07-10 12:49:38 +02:00
Noah Lancien
3d81cd77ce Merge branch 'trunk' 2025-07-09 15:31:20 +02:00
Noah Lancien
fba178b598 Merge branch 'develop' into trunk 2025-07-09 15:23:22 +02:00
noah.lancien
c6e5c5eeb7 Merge branch 'issue-74-format' into 'develop'
feat: allow svg files in tickets

See merge request ldc-web/projets/support-web!107
2025-07-09 13:20:57 +00:00
Corentin Huet
3c035aec9d feat: allow svg files in tickets 2025-07-09 15:08:49 +02:00
Noah Lancien
1f02f86610 Merge branch 'trunk' 2025-06-24 10:31:22 +02:00
Noah Lancien
efb3914e4f Merge branch 'develop' into trunk 2025-06-24 10:31:03 +02:00
noah.lancien
dd230c4516 Merge branch 'issue-92-consumer-tickets' into 'develop'
feat: add complaints enum for tickets

See merge request ldc-web/projets/support-web!106
2025-06-24 08:22:07 +00:00
Noah Lancien
6dd7278c4f feat: add complaints enum for tickets 2025-06-19 17:32:33 +02:00
Noah Lancien
b0f4c37153 Merge branch 'trunk' 2025-06-19 12:09:03 +02:00
Noah Lancien
25ab578c93 Merge branch 'develop' into trunk 2025-06-19 12:01:08 +02:00
Noah Lancien
2d0b300a52 ci: update image version + replace 443 port by 80 in manifest 2025-06-19 12:00:53 +02:00
Noah Lancien
52386bbfd4 Merge branch 'develop' into trunk 2025-06-19 11:48:17 +02:00
noah.lancien
748a5018af Merge branch 'issue-89' into 'develop'
feat: 💩 trying to fix invoices sorting, trying to make the delete cascade for site

See merge request ldc-web/projets/support-web!105
2025-06-19 09:47:47 +00:00
Noah Lancien
fbf4a2f96c fix: MR feedback 2025-06-19 11:46:01 +02:00
Noah Lancien
7089b11c5f fix: linkedTickets() method was called with a wrong name 2025-06-19 11:09:42 +02:00
Nicolas Demangeat
de14d846c5 feat: 💩 trying to fix invoices sorting, trying to make the delete cascade for site 2025-06-18 11:10:46 +02:00
Noah Lancien
d6ed7c1f04 Merge branch 'trunk' 2025-06-16 12:00:47 +02:00
Noah Lancien
5477affb97 Merge branch 'develop' into trunk 2025-06-16 11:52:26 +02:00
noah.lancien
77a7871f3d Merge branch 'issue-89' into 'develop'
fix 🐛 sort display invoices is now OK

See merge request ldc-web/projets/support-web!104
2025-06-16 09:50:42 +00:00
Nicolas Demangeat
c63f2b62e9 fix: 🎨 add condition to have invoiceModels sorted by query string or orderByDesc if no query string in InvoiceController 2025-06-16 10:54:46 +02:00
Nicolas Demangeat
4c8f5f20f7 fix: 🐛 add a default behavior in sortQuery method in Controller.php to have the query orderByDesc if no query string 2025-06-16 09:53:32 +02:00
Nicolas Demangeat
09d84e31fb fix 🐛 sort display invoices is now OK 2025-06-13 16:59:39 +02:00
Vincent BRIDIER
3e199d0f68
Merge branch 'trunk' 2025-05-27 10:30:17 +02:00
Vincent BRIDIER
7564600ace
Merge branch 'develop' into trunk 2025-05-27 10:30:05 +02:00
Vincent BRIDIER
88457bb44a
feat: Add Tickets state export notification 2025-05-27 10:29:56 +02:00
Vincent BRIDIER
ba6f7f8e7b
Merge branch 'trunk' 2025-05-12 15:11:13 +02:00
Vincent BRIDIER
f1eddb1cc2
Merge branch 'develop' into trunk 2025-05-12 15:10:59 +02:00
Vincent BRIDIER
7116c5d41f Merge branch 'issue-83' into 'develop'
fix: 🐛 change the blade condition to display or not the project manager

See merge request ldc-web/projets/support-web!103
2025-05-12 13:10:45 +00:00
Nicolas Demangeat
bc0d61d438 fix: ♻️ remove empty class 2025-05-12 15:09:50 +02:00
Nicolas Demangeat
aa49e077bd fix: 💄 refacto tickets show blade class to display the answer button always on the right 2025-05-12 15:08:05 +02:00
Nicolas Demangeat
a484335112 fix: 🐛 change the blade condition to display or not the project manager 2025-05-12 14:39:36 +02:00
Vincent BRIDIER
658fedd3eb
Merge branch 'trunk' 2025-05-12 11:42:21 +02:00
Vincent BRIDIER
31510149af
Merge branch 'develop' into trunk 2025-05-12 11:41:46 +02:00
Vincent BRIDIER
420947f8e0 Merge branch 'issue-83' into 'develop'
fix: 🐛 respond button is now displayed

See merge request ldc-web/projets/support-web!102
2025-05-12 09:39:59 +00:00
Nicolas Demangeat
17c10a1618 fix: 🐛 respond button is now displayed 2025-05-12 10:45:38 +02:00
Noah Lancien
fb8720d41b Merge branch 'trunk' 2025-04-24 15:02:27 +02:00
Noah Lancien
08afe201f8 Merge branch 'develop' into trunk 2025-04-24 15:02:07 +02:00
noah.lancien
db39f78281 Merge branch '81-gitlab-id-troubles-in-requests' into 'develop'
fix: allow null value for gitlab_id and fix update request for users

See merge request ldc-web/projets/support-web!101
2025-04-24 13:00:47 +00:00
Noah Lancien
ea29760b95 fix: allow null value for gitlab_id and fix update request for users 2025-04-24 14:52:52 +02:00
Noah Lancien
afd8f09d02 Merge branch 'trunk' 2025-04-23 12:11:56 +02:00
Noah Lancien
33cf4f1c93 Merge branch 'develop' into trunk 2025-04-23 12:11:30 +02:00
noah.lancien
83d4d5442f Merge branch 'issue-80' into 'develop'
feat: ✨ you can now edit the sent accounting date even when the date...

See merge request ldc-web/projets/support-web!100
2025-04-23 10:10:31 +00:00
Nicolas Demangeat
e66af8dc92 fix: refacto condition 2025-04-23 11:41:38 +02:00
Nicolas Demangeat
e595c7e145 feat: ✨ you can now edit the sent accounting date even when the date is present if you are admin 2025-04-23 11:12:41 +02:00
Vincent BRIDIER
e1944924c1
Merge branch 'trunk' 2025-04-18 10:28:51 +02:00
Vincent BRIDIER
3a0cc47fa8
Merge branch 'develop' into trunk 2025-04-18 10:14:27 +02:00
Vincent BRIDIER
770cb043c4
feat: Update manifest for db vars 2025-04-18 10:14:12 +02:00
Vincent BRIDIER
3a2b5a0af9
Merge branch 'develop' into trunk 2025-04-18 09:59:53 +02:00
Vincent BRIDIER
f1ddf3b101
feat: Update Ticket linking 2025-04-18 09:58:41 +02:00
Vincent BRIDIER
d9aa989984
feat: Add ticket title to gitlab issue title 2025-04-17 17:09:28 +02:00
Vincent BRIDIER
e12c48b829
feat: Add Gitlab id on user model 2025-04-17 17:05:50 +02:00
Vincent BRIDIER
eba20accc4
fix: Some fixes 2025-04-17 16:24:27 +02:00
Vincent BRIDIER
0bca962de9
feat: Add project manager on site model - Close #79 2025-04-17 16:22:23 +02:00
Vincent BRIDIER
bf6f35fdb1
feat: Close #78 - Add Create Gitlab issue for newsletter too 2025-04-17 11:15:39 +02:00
Vincent BRIDIER
af1c739f72
feat: Close #62 - Add Edit btn on ticket show 2025-04-17 11:00:20 +02:00
Vincent BRIDIER
16dd015290
fix: Fix MEP date validation and UX 2025-04-17 10:53:19 +02:00
Vincent BRIDIER
8bb823512d
fix: Fix ticket sorting 2025-04-17 10:47:05 +02:00
Vincent BRIDIER
4de74c8f5f
feat: Remove useless dutyhours and home 2025-04-11 18:41:09 +02:00
Vincent BRIDIER
e06558d8c6
feat: Update Ticket UI/UX 2025-04-11 18:30:04 +02:00
Noah Lancien
ca7057ce77 Merge branch 'develop' into trunk 2025-04-08 14:11:31 +02:00
noah.lancien
99744045e9 Merge branch 'issue-77-linking' into 'develop'
feat: ✨ added the possibility of linking tickets !77

See merge request ldc-web/projets/support-web!96
2025-04-08 12:11:06 +00:00
Corentin Huet
d58f697ed8 feat: ✨ added the possibility of linking tickets 2025-04-08 14:09:22 +02:00
noah.lancien
61833abfc5 Merge branch 'issue-76-mep' into 'develop'
Issue 76 date mep

See merge request ldc-web/projets/support-web!95
2025-04-08 10:30:36 +00:00
Corentin Huet
f9c02af11b feat: ✨ added mep date on tickets 2025-04-08 12:25:35 +02:00
noah.lancien
3836cc50e8 Merge branch 'issue-75-priority' into 'develop'
feat: ✨ using order method for set a priority to a ticket

See merge request ldc-web/projets/support-web!94
2025-04-08 10:02:48 +00:00
Alexis Gousseau
f932818c45 feat: ✨ set priority on tickets with order functionnality #75 2025-04-08 11:57:15 +02:00
Vincent BRIDIER
763d8e9467 Merge branch 'issue-69' into 'develop'
fix: 🐛 login page is now only accessible for unauth users #69

See merge request ldc-web/projets/support-web!98
2025-04-08 09:03:43 +00:00
Alexis Gousseau
14051a908e fix: 🐛 login page is now only accessible for unauth users #69 2025-04-08 10:49:27 +02:00
Corentin Huet
64b95f6f28 feat: ✨ add order on tickets 2025-04-08 09:46:47 +02:00
Noah Lancien
0dd283b68d Merge branch 'trunk' 2025-04-07 15:01:11 +02:00
Noah Lancien
7c028a4505 Merge branch 'develop' into trunk 2025-04-07 15:00:52 +02:00
noah.lancien
397ed4272b Merge branch 'ticket-management' into 'develop'
feat: 🐛 replace sebastien by nicolas in GitlabUsersEnum

See merge request ldc-web/projets/support-web!97
2025-04-07 12:59:29 +00:00
Nicolas Demangeat
cef170adaa fix: 🐛 change the id in GitlabUsersEnum an remove unuse user 2025-04-07 14:55:09 +02:00
Nicolas Demangeat
1506891d21 feat: 🐛 replace sebastien by nicolas in GitlabUsersEnum 2025-04-07 14:44:20 +02:00
Vincent BRIDIER
8d6723f262
feat: Update README.md 2025-03-13 07:48:29 +01:00
Vincent BRIDIER
4367c35976
feat: Update README.md project name 2025-03-13 07:43:22 +01:00
Karl Muller
b21dd4d260 Merge branch 'trunk' 2025-03-07 14:27:01 +00:00
Karl Muller
4838b54b4c Merge branch 'develop' into trunk 2025-03-07 14:26:49 +00:00
Karl Muller
9b0f1e0241 fix: add php v on Dockerfile 2025-03-07 14:25:57 +00:00
Karl Muller
911ee5df4b Merge branch 'trunk' 2025-03-07 14:10:23 +00:00
Karl Muller
bbfd4360f2 Merge branch 'develop' into trunk 2025-03-07 14:09:58 +00:00
karl.muller
2786972b41 Merge branch 'chore/laravel11' into 'develop'
chore: 📦 bump in laravel 11 + robots.txt

See merge request ldc-web/projets/support-web!93
2025-03-07 14:09:05 +00:00
Karl Muller
a8605236a7 chore: 📦 bump in laravel 11 + robots.txt 2025-03-07 10:28:17 +00:00
Vincent BRIDIER
3a51ccb0f3
Merge branch 'trunk' 2025-03-04 09:58:05 +01:00
Vincent BRIDIER
1c3f20782b
Merge branch 'develop' into trunk 2025-03-04 09:57:56 +01:00
Vincent BRIDIER
25f31ff7b2 Update TaskTypeEnum.php 2025-03-04 08:56:58 +00:00
Noah Lancien
673494aeda Merge branch 'trunk' 2025-02-20 14:41:26 +01:00
Noah Lancien
1bd04e2e52 Merge branch 'develop' into trunk 2025-02-20 14:41:11 +01:00
noah.lancien
fa1d8db4b2 Merge branch 'issue-72' into 'develop'
feat: ✨ add recetteValidated to TicketStatusEnum

See merge request ldc-web/projets/support-web!92
2025-02-20 13:40:44 +00:00
Nicolas Demangeat
372fadb865 feat: ✨ add recetteValidated to TicketStatusEnum 2025-02-20 10:12:11 +01:00
Noah Lancien
aa17aab45f Merge branch 'trunk' 2025-02-14 13:42:22 +01:00
Noah Lancien
ec47d2610f Merge branch 'develop' into trunk 2025-02-14 13:42:08 +01:00
Noah Lancien
df9d8d69fa fix: updated type filter icon 2025-02-14 13:42:00 +01:00
Noah Lancien
560ef30cd8 Merge branch 'trunk' 2025-02-14 13:31:00 +01:00
Noah Lancien
b2908aac9f Merge branch 'develop' into trunk 2025-02-14 13:30:20 +01:00
noah.lancien
59415e1926 Merge branch 'issue-73-type-filter' into 'develop'
feat: Add type filter

See merge request ldc-web/projets/support-web!91
2025-02-14 12:29:39 +00:00
Noah Lancien
aaf114fa30 feat: Add type filter 2025-02-14 13:26:45 +01:00
Karl Muller
0da4a6fa13 Merge branch 'trunk' 2025-01-13 13:56:41 +00:00
Karl Muller
b6720bae3d Merge branch 'develop' into trunk 2025-01-13 13:46:09 +00:00
Karl Muller
a58bf2ff3b fix: change manifest for cron issue 2025-01-13 13:45:04 +00:00
Karl Muller
4c4a18ac70 fix: composer update to fix CVE 2025-01-13 13:44:22 +00:00
Noah Lancien
2b94d780b6 Merge branch 'trunk' 2024-11-26 09:18:29 +01:00
Noah Lancien
74edc5c785 Merge branch 'develop' into trunk 2024-11-26 09:17:42 +01:00
Noah Lancien
4de7a0c5ca fix: remove brackets for Invoice->tasks 2024-11-26 09:17:19 +01:00
Noah Lancien
781161c5e4 Merge branch 'trunk' 2024-11-25 17:19:55 +01:00
Noah Lancien
2d70ff9f29 Merge branch 'develop' into trunk 2024-11-25 17:18:41 +01:00
Noah Lancien
27258558a7 chore: composer update to fix some CVE 2024-11-25 17:18:25 +01:00
Noah Lancien
17a01e1f7a Merge branch 'trunk' 2024-11-25 17:12:45 +01:00
Karl Muller
e3d828a9e5 Merge branch 'develop' into trunk 2024-11-25 15:50:32 +00:00
karl.muller
9a1f23b85f Merge branch 'issue-70' into 'develop'
feat: 💄 improve invoice pdf

See merge request ldc-web/projets/support-web!90
2024-11-25 15:48:53 +00:00
Nicolas Demangeat
260e109ba1 feat: 💄 improve invoice pdf 2024-11-25 15:58:56 +01:00
Noah Lancien
d17678342e Merge branch 'trunk' 2024-11-12 14:32:29 +01:00
Noah Lancien
b646cb41fe Merge branch 'develop' into trunk 2024-11-12 14:07:35 +01:00
Noah Lancien
8f690473f8 chore: phpcs 2024-11-12 14:06:31 +01:00
noah.lancien
cc7a9b54e5 Merge branch 'issue-67' into 'develop'
Issue 67

See merge request ldc-web/projets/support-web!88
2024-11-12 13:02:58 +00:00
Noah Lancien
5e459a6571 fix: some elements crashed since the inscrease of files in tickets and messages 2024-11-12 12:52:21 +01:00
Vincent BRIDIER
2f80eb5853 Update README 2024-08-19 07:53:58 +00:00
Vincent BRIDIER
0ebdc9a984 Update README 2024-08-19 07:53:38 +00:00
Noah Lancien
5bd7673a18 Merge branch 'trunk' 2024-07-31 12:21:21 +02:00
Noah Lancien
2faf043f68 Merge branch 'develop' into trunk 2024-07-31 12:12:17 +02:00
noah.lancien
a44ee6f83c Merge branch 'issue-68' into 'develop'
fix: deleted user management for estimation

See merge request ldc-web/projets/support-web!89
2024-07-31 10:10:40 +00:00
Nicolas Demangeat
6ae38392ea fix: deleted user management for estimation 2024-07-31 12:02:15 +02:00
Nicolas Demangeat
c770d5d80e feat: you can set the amout by 0.5hours now, improve display in invoice show blade 2024-07-29 15:20:57 +02:00
Nicolas Demangeat
e7c1acf8a4 feat: can add 3 files for messages and 5 for tickets 2024-07-29 14:23:37 +02:00
Nicolas Demangeat
23e296978d wip: mimes type for ticket files 2024-07-29 08:47:28 +02:00
Vincent BRIDIER
66c889b02a
Merge branch 'trunk' 2024-07-26 15:33:24 +02:00
Vincent BRIDIER
74600ef3a7
Merge branch 'develop' into trunk 2024-07-26 15:06:54 +02:00
Vincent BRIDIER
889ee1e7f4
Update SP management for SAML 2024-07-26 15:06:30 +02:00
Vincent BRIDIER
738cfb7aea
PHPCS 2024-07-26 15:05:16 +02:00
Vincent BRIDIER
35e18112b9
Merge branch 'develop' into trunk 2024-07-25 17:29:35 +02:00
Vincent BRIDIER
b024dbd007
Fix SAML without CSP on login + idp pem loading 2024-07-25 17:29:19 +02:00
Nicolas Demangeat
a4d0b131a4 feat: wip, validation tickets and messages request 2024-07-23 13:44:51 +02:00
Nicolas Demangeat
c23e2289e5 feat: wip issue 67 2024-07-22 11:32:03 +02:00
Vincent BRIDIER
f10b46a012
Merge branch 'trunk' 2024-07-20 23:18:59 +02:00
Vincent BRIDIER
523715a3c1
Merge branch 'develop' into trunk 2024-07-20 23:01:04 +02:00
Vincent BRIDIER
2eacc46be0
Add SAML deps for IDP feature 2024-07-20 23:00:34 +02:00
Vincent BRIDIER
c8b4f97c88
Merge branch 'trunk' 2024-07-10 15:23:32 +02:00
Vincent BRIDIER
65b92edc99
Merge branch 'develop' into trunk 2024-07-10 15:23:17 +02:00
Vincent BRIDIER
0874e9202c Merge branch 'issue-64' into 'develop'
fix: InvoiceTasksComponent and invoice.blade

See merge request ldc-web/projets/support-web!87
2024-07-10 09:06:39 +00:00
nicolas.demangeat
ae68ce0f16 fix: InvoiceTasksComponent and invoice.blade
Close #64
2024-07-10 09:06:38 +00:00
Thibault Raquet
2ee245be4c Merge branch 'trunk' into 'master'
Trunk

See merge request ldc-web/projets/support-web!86
2024-06-27 08:58:58 +00:00
Thibault Raquet
766a990361 Merge branch 'develop' into 'trunk'
Develop

See merge request ldc-web/projets/support-web!85
2024-06-27 08:58:33 +00:00
Thibault Raquet
dc47b8d6e2 Merge branch 'prod-migration' into 'develop'
Prod migration

See merge request ldc-web/projets/support-web!84
2024-06-27 08:58:01 +00:00
Thibault Raquet
fad9d1207f Prod migration 2024-06-27 08:58:01 +00:00
Vincent BRIDIER
a23509fa09
Merge branch 'trunk' 2024-06-11 10:22:48 +02:00
Vincent BRIDIER
6c8cc25bae
Merge branch 'develop' into trunk 2024-06-11 10:07:26 +02:00
Vincent BRIDIER
af4509c7ca Merge branch 'fixed-invoices-new-lines' into 'develop'
Fix: Invoices new lines are now displayed

See merge request ldc-web/projets/support-web!83
2024-06-11 08:06:42 +00:00
Vincent BRIDIER
58280dd384 Merge branch 'invoice-search' into 'develop'
Invoice search

See merge request ldc-web/projets/support-web!81
2024-06-11 08:06:16 +00:00
Vincent BRIDIER
4da19cb742 Merge branch 'invoice-query-update' into 'develop'
add ->orderByDesc to the invoiceModels query in InvoiceController

See merge request ldc-web/projets/support-web!80
2024-06-11 08:04:56 +00:00
Vincent BRIDIER
0c34b4ebbf Merge branch 'add-estimation' into 'develop'
add account->balance in form-inputs for estimations

See merge request ldc-web/projets/support-web!79
2024-06-11 08:04:29 +00:00
Vincent BRIDIER
2eeb29d98b Merge branch 'modif-ticketStatusEnum' into 'develop'
change estimateTodo name in TicketStatusEnum

See merge request ldc-web/projets/support-web!78
2024-06-11 08:03:41 +00:00
nicolas.demangeat
b64dbf3eed change estimateTodo name in TicketStatusEnum 2024-06-11 08:03:40 +00:00
Noah Lancien
5128ba471b Fix: Invoices new lines are now displayed 2024-06-11 09:45:12 +02:00
Nicolas Demangeat
daad752be1 add site_id to invoices research in InvoiceController 2024-06-03 16:57:47 +02:00
Nicolas Demangeat
2f1976bf83 add ->orderByDesc to the invoiceModels query in InvoiceController 2024-06-03 16:43:27 +02:00
Nicolas Demangeat
4eda19604c add account->balance in form-inputs for estimations 2024-06-03 16:31:05 +02:00
Vincent BRIDIER
704551c165 Merge branch 'fix-ticket-show' into 'develop'
Fix ticket show

See merge request ldc-web/projets/support-web!77
2024-02-05 14:40:21 +00:00
nicolas.demangeat
08a92a1d97 Fix ticket show 2024-02-05 14:40:20 +00:00
Vincent BRIDIER
3c529a7bc0
Merge branch 'trunk' 2024-02-05 12:17:39 +01:00
Vincent BRIDIER
c8d179e7b3
Merge branch 'develop' into trunk 2024-02-05 12:09:45 +01:00
Vincent BRIDIER
af97d31fc3 Merge branch 'fix-ticket-show' into 'develop'
fix ticket show blade

See merge request ldc-web/projets/support-web!76
2024-02-05 11:09:10 +00:00
nicolas.demangeat
d3a01593a3 fix ticket show blade 2024-02-05 11:09:10 +00:00
Vincent BRIDIER
8e4d6d4198
Merge branch 'develop' into trunk 2024-02-02 11:34:37 +01:00
Vincent BRIDIER
434dd45a5d Merge branch 'add-ticket-title' into 'develop'
add field for the title of a ticket, make the migration and the request

See merge request ldc-web/projets/support-web!72
2024-02-02 10:34:06 +00:00
nicolas.demangeat
9675c1bb3a add field for the title of a ticket, make the migration and the request 2024-02-02 10:34:06 +00:00
Vincent BRIDIER
4cd2980227 Merge branch 'issue-56' into 'develop'
change class attribut to text-bg-dark in tickets show blade line 179

See merge request ldc-web/projets/support-web!75
2024-02-01 08:42:56 +00:00
Nicolas Demangeat
67a364afe8 change class attribut to text-bg-dark in tickets show blade line 179 2024-02-01 09:41:30 +01:00
Vincent BRIDIER
a3c2697c86
Merge branch 'trunk' 2024-01-31 18:03:13 +01:00
Vincent BRIDIER
c6d89101b4
Merge branch 'develop' into trunk 2024-01-31 17:55:33 +01:00
Vincent BRIDIER
e17a415fad Merge branch '50-invoices-search-ref' into 'develop'
update searchfield for invoices

See merge request ldc-web/projets/support-web!74
2024-01-31 16:54:39 +00:00
Vincent BRIDIER
6a53d7ec45 Merge branch '53-devis-changement-de-restrictions-sur-les-montants-des-lignes' into 'develop'
update invoices request

See merge request ldc-web/projets/support-web!73
2024-01-31 16:52:10 +00:00
Vincent BRIDIER
8687adfa30 Merge branch '52-devis-saisie-de-commentaires' into 'develop'
remove condition in invoices form-inputs

See merge request ldc-web/projets/support-web!71
2024-01-31 16:44:28 +00:00
Vincent BRIDIER
b762dfc053 Update manifest 2023-12-11 11:13:53 +00:00
Nicolas Demangeat
8a3e175cd0 update searchfield for invoices 2023-11-14 09:45:16 +01:00
Nicolas Demangeat
ab43676c0a update invoices request 2023-11-14 09:37:49 +01:00
Nicolas Demangeat
c192991470 remove condition in invoices form-inputs 2023-11-13 14:31:12 +01:00
Vincent BRIDIER
ad43378b52
Merge branch 'trunk' 2023-10-13 15:23:19 +02:00
Vincent BRIDIER
f40f2e2aa5
Merge branch 'develop' into trunk 2023-10-13 15:16:29 +02:00
Vincent BRIDIER
b301e53c34 Fix #49 2023-10-13 13:15:10 +00:00
Vincent BRIDIER
75d03386f3 Merge branch 'issue-48' into 'develop'
Issue 48

See merge request ldc-web/projets/support-web!70
2023-10-13 13:14:19 +00:00
Jérémy Munsch
3126bd9e92
Fixes #48 invoice comment was not printed in html 2023-10-13 10:56:20 +02:00
Jérémy Munsch
1b1cb44650
composer update 2023-10-13 10:47:58 +02:00
Vincent BRIDIER
b55d812aaa Merge branch 'develop' into trunk 2023-10-12 16:55:19 +02:00
Vincent BRIDIER
8c19bc9785 Merge branch 'issue-45' into 'develop'
Closes #45 Allow update comment on invoice

See merge request ldc-web/projets/support-web!69
2023-10-12 14:54:46 +00:00
Vincent BRIDIER
74bdeb7383 Merge branch 'issue-47' into 'develop'
Issue 47

See merge request ldc-web/projets/support-web!68
2023-10-12 14:52:23 +00:00
Jérémy Munsch
e3fddc1593
Closes #45 Allow update comment on invoice 2023-10-12 16:30:43 +02:00
Vincent BRIDIER
ab08bad87e Merge branch 'trunk' 2023-10-12 11:47:11 +02:00
Vincent BRIDIER
e8b920a8cd Merge branch 'develop' into trunk 2023-10-12 11:18:37 +02:00
Vincent BRIDIER
cb779c83b8
Merge branch 'trunk' 2023-10-09 15:09:26 +02:00
Vincent BRIDIER
a393b24392
Merge branch 'develop' into trunk 2023-10-04 11:38:28 +02:00
Vincent BRIDIER
cd89f6b443 Merge branch 'trunk' 2023-08-24 16:21:39 +02:00
Vincent BRIDIER
d9b316eae4 Merge branch 'develop' into trunk 2023-08-24 16:01:54 +02:00
Vincent BRIDIER
722369cf61 Merge branch 'develop' into trunk 2023-08-24 12:37:14 +02:00
Vincent BRIDIER
0cc315d2ef Merge branch 'develop' into trunk 2023-08-24 12:35:08 +02:00
Vincent BRIDIER
7559a47044
Merge branch 'trunk' 2023-08-18 12:37:30 +02:00
Vincent BRIDIER
55fef3421e
Merge branch 'develop' into trunk 2023-08-18 12:37:14 +02:00
Vincent BRIDIER
97d8111f4b
Merge branch 'trunk' 2023-08-17 11:21:13 +02:00
Vincent BRIDIER
4354f6a445
Merge branch 'develop' into trunk 2023-08-17 11:18:26 +02:00
Vincent BRIDIER
abdbbae843
Merge branch 'develop' into trunk 2023-08-16 12:24:45 +02:00
Vincent BRIDIER
f150e96d39
Merge branch 'develop' into trunk 2023-08-16 10:30:48 +02:00
Vincent BRIDIER
d2324145a4
Merge branch 'develop' into trunk 2023-08-14 11:24:22 +02:00
Vincent BRIDIER
b6c74efd3d
Merge branch 'trunk' 2023-07-20 15:31:37 +02:00
Vincent BRIDIER
57a437db48
Merge branch 'develop' into trunk 2023-07-20 15:31:24 +02:00
Vincent BRIDIER
f3cb8e7974
Merge branch 'trunk' 2023-06-30 09:14:08 +02:00
Vincent BRIDIER
91c1fe5532
Merge branch 'develop' into trunk 2023-06-30 09:13:52 +02:00
Vincent BRIDIER
29a837ff61
Merge branch 'trunk' 2023-06-29 10:12:31 +02:00
Vincent BRIDIER
bbe4478c09
Merge branch 'develop' into trunk 2023-06-29 10:12:14 +02:00
Vincent BRIDIER
28ee9f593d
Merge branch 'trunk' 2023-06-22 14:58:09 +02:00
Vincent BRIDIER
eb2d4e5267
Merge branch 'develop' into trunk 2023-06-22 14:57:42 +02:00
Vincent BRIDIER
c19d5829e6
Merge branch 'trunk' 2023-04-25 11:35:01 +02:00
Vincent BRIDIER
c1fb743e34
Merge branch 'develop' into trunk 2023-04-25 11:34:24 +02:00
Vincent BRIDIER
1d07c93799
Merge branch 'trunk' 2023-04-18 17:27:35 +02:00
Vincent BRIDIER
32cb11622c
Merge branch 'develop' into trunk 2023-04-18 17:27:21 +02:00
Vincent BRIDIER
911d7a2f6d
Merge branch 'trunk' 2023-04-17 17:21:58 +02:00
Vincent BRIDIER
32be1746b5
Merge branch 'develop' into trunk 2023-04-17 16:22:06 +02:00
Vincent BRIDIER
a5d4c58604
Merge branch 'develop' into trunk 2023-04-12 15:47:13 +02:00
Vincent BRIDIER
0d6f34b05a
Merge branch 'trunk' 2022-12-15 09:10:57 +01:00
Vincent BRIDIER
606ca09608
Merge branch 'develop' into trunk 2022-12-15 09:10:38 +01:00
Jérémy Munsch
6523875860
Merge branch 'trunk' 2022-11-04 17:04:58 +01:00
Jérémy Munsch
83b7e42b90
Merge branch 'develop' into trunk 2022-11-04 17:03:49 +01:00
Jérémy Munsch
6f20a6b8db
Merge branch 'develop' into trunk 2022-10-13 10:15:36 +02:00
Jérémy Munsch
88f3da4c92
Merge branch 'hotfix' 2022-10-12 14:22:46 +02:00
Vincent BRIDIER
bd3133f06c
Merge branch 'trunk' 2022-10-11 12:06:30 +02:00
Vincent BRIDIER
bb2cbc5ad8
Merge branch 'develop' into trunk 2022-10-11 12:06:06 +02:00
228 changed files with 14438 additions and 6473 deletions

View file

@ -30,19 +30,17 @@ MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=noreply-sw@ldc.fr
MAIL_FROM_NAME="${APP_NAME}"
MAIL_LIST_SERVICEWEB=equipe.web@ldc.fr
MAIL_ADMIN=equipe.web@ldc.fr
MAIL_LIST_SERVICEWEB=digital@ldc.fr
MAIL_ADMIN=digital@ldc.fr
# Sentry
SENTRY_LARAVEL_DSN=
# ADMIN SECURE
# - API ENDPOINT (Optional)
LDC_WEB_API_ENDPOINT=
# - API KEY
LDC_WEB_API_KEY=
# UWIL ADMIN SECURE
# - LIST SEPARATED WITH ',' (Required)
UWIL_ADMIN_SECURE_CIDR_LIST=""
# - LIST SEPARATED WITH ',' (Optional)
LDC_WEB_CIDR_MANUAL_ALLOWED_LIST=
UWIL_ADMIN_SECURE_CIDR_PROJECT_ALLOWED_LIST=
# GITLAB API
GITLAB_URL=

5
.gitignore vendored
View file

@ -21,3 +21,8 @@ Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
storage/samlidp/*
.npmrc
.zshrc
.npm/
.composer/

View file

@ -7,7 +7,7 @@ include:
file: 'security/security.yml'
- project: 'ldc-web/shared-ci'
ref: 'main'
file: 'build/build.yml'
file: "build/docker-multistage.yml"
- project: 'ldc-web/shared-ci'
ref: 'main'
file: 'test/test.yml'

View file

@ -1,5 +1,43 @@
FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/ldcweb-production-8.2:latest
COPY --chown=www-data:www-data . /app/srcs
FROM composer:2.9.2 AS vendor
ARG GITLAB_USER
ARG GITLAB_PASSWORD
COPY database/ database/
COPY composer.json composer.json
COPY composer.lock composer.lock
RUN composer config gitlab-token.lab.s-web.fr ${GITLAB_USER} ${GITLAB_PASSWORD}
RUN composer install \
--ignore-platform-reqs \
--no-interaction \
--no-plugins \
--no-scripts \
--no-dev \
--prefer-dist
FROM node:20.18 AS frontend
ARG GITLAB_PASSWORD
RUN mkdir -p /app/public/build
COPY package*.json tsconfig.json vite.config.ts .eslintrc.json .stylelintrc.json /app/
COPY resources/ /app/resources/
WORKDIR /app
RUN npm config set @uwil:registry https://lab.s-web.fr/api/v4/groups/ldc-web/-/packages/npm/
RUN npm config set -- '//lab.s-web.fr/api/v4/groups/ldc-web/-/packages/npm/:_authToken' "${GITLAB_PASSWORD}"
RUN npm ci --no-audit --no-fund --loglevel=error && npm run prod
FROM registry.s-web.fr/ldc-web/projets/ldc-web-images-docker/uwil-production-8.5:${PHP_8_5_TAG}
ARG USER=www-data
COPY --chown=${USER}:${USER} . /app/srcs
COPY --from=vendor --chown=${USER}:${USER} /app/vendor/ /app/srcs/vendor/
COPY --from=frontend --chown=${USER}:${USER} /app/public/build/ /app/srcs/public/build/
USER root
RUN chmod -R 755 /app/srcs/storage
USER www-data
USER ${USER}

View file

@ -1,3 +1,17 @@
# TODO
# UWIL Support
PROD : support.uwil.fr
RE7 : support-web.re7-s-web.fr
## Gitlab Intégration
Le token de groupe pour l'intégration est valable 11 mois
Il faut le renouveler ici : https://lab.s-web.fr/groups/ldc-web/projets/-/settings/access_tokens et le nommer SW Intégration
Role : Guest
Scope : api
## TODO
- App\Models\Message:booted(): investigate why this make errors on prod,

4633
_ide_helper.php Normal file

File diff suppressed because it is too large Load diff

View file

@ -117,7 +117,7 @@ class CreateUser extends Command
{
while (is_null($this->email)) {
try {
$tmp = $this->ask('Type the wanted user email', 'equipe.web@ldc.fr');
$tmp = $this->ask('Type the wanted user email', 'digital@ldc.fr');
$validator = Validator::make(['email' => $tmp], [
'email' => 'required|unique:users,email|email:rfc,dns'
]);

View file

@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands;
use App\Jobs\ExportTicketsState as JobsExportTicketsState;
use Illuminate\Console\Command;
class ExportTicketsState extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'tickets:export-state';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Export the state of tickets to a CSV file';
/**
* Execute the console command.
*
* @return integer
*/
public function handle()
{
$this->info('Running the Job, this could take some time.');
$job = new JobsExportTicketsState();
$job->handle();
$this->info('Job completed');
return 0;
}
}

View file

@ -19,7 +19,7 @@ class TestMail extends Command
*
* @var string
*/
protected $description = 'Send test email to equipe.web@ldc.fr';
protected $description = 'Send test email to digital@ldc.fr';
/**
* Execute the console command.
@ -29,7 +29,7 @@ class TestMail extends Command
public function handle()
{
Mail::raw(sprintf('UWIL mail-test from %s %s', \config('app.name'), \config('app.url')), function ($msg) {
$msg->to('equipe.web@ldc.fr')->subject('Test Email');
$msg->to('digital@ldc.fr')->subject('Test Email');
});
return 0;
}

View file

@ -0,0 +1,334 @@
<?php
namespace App\Console\Commands;
use App\Enums\Tickets\TicketStatusEnum;
use App\Models\GitlabIssues;
use App\Models\GitlabLabels;
use App\Models\GitlabMilestones;
use App\Models\GitlabProjects;
use App\Models\Ticket;
use Carbon\Carbon;
use GrahamCampbell\GitLab\Facades\GitLab;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
class UpdateGitlabDatas extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:update-gitlab-datas {--is-cron}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Fetch some Gitlab datas';
/**
* Execute the console command.
*
* @return void
*/
public function handle(): void
{
$isCron = $this->option('is-cron');
$groupId = 23;
$this->updateProjectsByGroup($groupId);
$this->updateLabelsByGroup($groupId);
$projects = GitlabProjects::all();
foreach ($projects as $project) {
$this->updateMilestonesByProject($project);
$this->updateIssuesByProject($project, $isCron);
}
$this->syncTicketStatus();
}
/**
* updateProjectsByGroup function
*
* @param integer $groupId
* @return void
*/
private function updateProjectsByGroup(int $groupId): void
{
$allProjects = [];
$page = 1;
do {
$projects = GitLab::groups()->projects($groupId, [
'order_by' => 'created_at',
'sort' => 'asc',
'per_page' => 100,
'page' => $page,
'include_subgroups' => true
]);
$allProjects = array_merge($allProjects, $projects);
$page++;
} while (!empty($projects));
$this->info(sprintf(
"Fetched %d projects in group %d.",
count($allProjects),
$groupId
));
foreach ($allProjects as $project) {
GitlabProjects::upsert(
[
'name' => $project['name'],
'url' => $project['web_url'],
'is_archived' => $project['archived'],
'gitlab_id' => $project['id']
],
['gitlab_id']
);
}
$this->info("Gitlab Projects upsert complete.");
}
/**
* updateLabelsByGroup function
*
* @param integer $groupId
* @return void
*/
private function updateLabelsByGroup(int $groupId): void
{
$allLabels = [];
$page = 1;
do {
$labels = GitLab::groups()->labels($groupId, [
'per_page' => 100,
'page' => $page,
]);
$allLabels = array_merge($allLabels, $labels);
$page++;
} while (!empty($labels));
$this->info(sprintf(
"Fetched %d labels in group %d.",
count($allLabels),
$groupId
));
foreach ($allLabels as $project) {
GitlabLabels::upsert(
[
'name' => $project['name'],
'gitlab_id' => $project['id']
],
['gitlab_id']
);
}
$this->info("Gitlab labels upsert complete.");
}
/**
* updateIssuesByProject function
*
* @param GitlabProjects $project
* @param boolean $isCron
* @return void
*/
private function updateIssuesByProject(GitlabProjects $project, bool $isCron = false): void
{
$projectId = $project->gitlab_id;
$allIssues = [];
$page = 1;
do {
$params = [
'order_by' => 'created_at',
'sort' => 'asc',
'per_page' => 100,
'page' => $page,
'state' => 'all',
];
if ($isCron) {
$params = array_merge($params, ['updated_after' => now()->subDay()]);
}
$issues = GitLab::projects()->issues($projectId, $params);
$allIssues = array_merge($allIssues, $issues);
$page++;
} while (!empty($issues));
$this->info(sprintf(
"Fetched %d issues in project %d.",
count($allIssues),
$projectId
));
foreach ($allIssues as $issue) {
GitlabIssues::upsert(
[
'title' => $issue['title'],
'url' => $issue['web_url'],
'estimate_time' => $issue['time_stats']['time_estimate'] ?? 0,
'spent_time' => $issue['time_stats']['total_time_spent'] ?? 0,
'is_closed' => $issue['state'] === 'closed',
'gitlab_id' => $issue['id'],
'gitlab_iid' => $issue['iid'],
'milestone_iid' => $issue['milestone']['iid'] ?? null,
'gitlab_project_id' => $projectId,
'g_created_at' => Carbon::parse($issue['created_at'])->format('Y-m-d'),
'g_updated_at' => Carbon::parse($issue['updated_at'])->format('Y-m-d'),
'g_closed_at' => !is_null($issue['closed_at'])
? Carbon::parse($issue['closed_at'])->format('Y-m-d')
: null,
'g_due_date' => !is_null($issue['due_date'])
? Carbon::parse($issue['due_date'])->format('Y-m-d')
: null
],
['gitlab_id']
);
$issueModel = GitlabIssues::where('gitlab_id', $issue['id'])->firstOrFail();
$labelIds = [];
foreach ($issue['labels'] as $labelName) {
$label = Cache::remember("gitlab_label_{$labelName}", 300, function () use ($labelName) {
return GitlabLabels::where('name', $labelName)->first();
});
if ($label) {
$labelIds[] = $label;
}
}
$issueModel->gitlabLabels()->sync($labelIds);
}//end foreach
$this->info("Gitlab issues upsert complete.");
}
/**
* updateMilestonesByProject function
*
* @param GitlabProjects $project
* @return void
*/
private function updateMilestonesByProject(GitlabProjects $project): void
{
$projectId = $project->gitlab_id;
$allMilestones = [];
$page = 1;
do {
$milestones = [];
try {
$milestones = GitLab::milestones()->all($projectId, [
'per_page' => 100,
'page' => $page
]);
} catch (\Exception $e) {
if ($e->getCode() === 404) {
if ($project->delete()) {
Log::warning(sprintf(
"Project not found (%s), it has been deleted.",
$projectId
));
} else {
Log::warning(sprintf(
"Project not found (%s).",
$projectId
));
}
} else {
Log::error(sprintf(
'API Error for project %s, Message: %d',
$projectId,
$e->getMessage()
));
report($e);
}
}
$allMilestones = array_merge($allMilestones, $milestones);
$page++;
} while (!empty($milestones));
$this->info(sprintf(
"Fetched %d milestones in project %d.",
count($allMilestones),
$projectId
));
foreach ($allMilestones as $milestone) {
GitlabMilestones::upsert(
[
'title' => $milestone['title'],
'url' => $milestone['web_url'],
'is_closed' => $milestone['state'] === 'closed',
'gitlab_id' => $milestone['id'],
'gitlab_iid' => $milestone['iid'],
'gitlab_project_id' => $projectId,
'g_created_at' => Carbon::parse($milestone['created_at'])->format('Y-m-d'),
'g_updated_at' => Carbon::parse($milestone['updated_at'])->format('Y-m-d'),
'g_start_date' => !is_null($milestone['start_date'])
? Carbon::parse($milestone['start_date'])->format('Y-m-d')
: null,
'g_due_date' => !is_null($milestone['due_date'])
? Carbon::parse($milestone['due_date'])->format('Y-m-d')
: null
],
['gitlab_id']
);
}//end foreach
$this->info("Gitlab milestones upsert complete.");
}
/**
* Synchronizes ticket statuses based on GitLab issue labels.
*
* @return void
*/
private function syncTicketStatus(): void
{
$tickets = Ticket::whereNotNull('gitlab_issue')->whereNot('status', TicketStatusEnum::archived)->get();
foreach ($tickets as $ticket) {
$gitlabIssue = GitlabIssues::where('url', $ticket->gitlab_issue)->with('gitlabLabels')->first();
$gitlabIssueLabels = $gitlabIssue ? $gitlabIssue->gitlabLabels->pluck('name') : [];
if ($gitlabIssueLabels) {
match (true) {
$gitlabIssueLabels->contains('g-wip') => $this->updateTicketStatus($ticket, TicketStatusEnum::inDev),
$gitlabIssueLabels->contains('g-production') => $this->updateTicketStatus($ticket, TicketStatusEnum::production),
default => null,
};
}
}
}
/**
* Updates the ticket status only if it has changed.
*
* @param Ticket $ticket The ticket to update.
* @param TicketStatusEnum $status The new status to apply.
*
* @return void
*/
private function updateTicketStatus(Ticket $ticket, TicketStatusEnum $status): void
{
if ($ticket->status !== $status && $ticket->status !== TicketStatusEnum::waiting) {
$ticket->status = $status;
$ticket->saveOrFail();
}
}
}

View file

@ -3,6 +3,7 @@
namespace App\Console;
use App\Jobs\AutoCloseOldTickets;
use App\Jobs\ExportTicketsState;
use App\Jobs\WarnBeforeAutoCloseTicket;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
@ -24,8 +25,10 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
$schedule->job(ExportTicketsState::class)->weekly()->fridays()->at('14:00');
$schedule->job(AutoCloseOldTickets::class)->dailyAt('08:00');
$schedule->job(WarnBeforeAutoCloseTicket::class)->dailyAt('08:05');
$schedule->command('app:update-gitlab-datas --is-cron')->hourly()->between('7:00', '19:00');
}
/**

View file

@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Dto;
final readonly class BrevoWebHookDto
{
public function __construct(
public readonly string $plainTextContent,
public readonly ?string $brand
) {}
}

View file

@ -0,0 +1,49 @@
<?php
namespace App\Enums\Credit;
use App\Traits\Enums\BaseEnum;
enum EstimationTimeEnum: int
{
use BaseEnum;
case halfHour = 0.0625;
case hour = 0.125;
case hourAndHalf = 0.1875;
case twoHours = 0.25;
case twoHoursAndHalf = 0.3125;
case threeHours = 0.375;
case threeHoursAndHalf = 0.4375;
case fourHours = 0.5;
case fourHoursAndHalf = 0.5625;
case fiveHours = 0.625;
case fiveHoursAndHalf = 0.6875;
case sixHours = 0.75;
case sixHoursAndHalf = 0.8125;
case sevenHours = 0.875;
case sevenHoursAndHalf = 0.9375;
case eightHours = 1;
/**
* Optionnal labels definition
*/
private const LABELS = [
self::halfHour->name => "Une demi-heure",
self::hour->name => "Une heure",
self::hourAndHalf->name => "Une heure et demie",
self::twoHours->name => "Deux heures",
self::twoHoursAndHalf->name => "Deux heures et demie",
self::threeHours->name => "Trois heures",
self::twoHoursAndHalf->name => "Trois heures et demie",
self::fourHours->name => "Quatre heures",
self::fourHoursAndHalf->name => "Quatre heures et demie",
self::fiveHours->name => "Cinq heures",
self::fiveHoursAndHalf->name => "Cinq heures et demie",
self::sixHours->name => "Six heures",
self::sixHoursAndHalf->name => "Six heures et demie",
self::sevenHours->name => "Sept heures",
self::sevenHoursAndHalf->name => "Sept heures et demi",
self::eightHours->name => "Huit heures",
];
}

View file

@ -8,10 +8,12 @@ enum InvoiceStatusEnum: int
{
use BaseEnum;
case opened = 1;
case refused = 2;
case canceled = 3;
case archived = 4;
case opened = 1;
case refused = 2;
case canceled = 3;
case archived = 4;
case awaiting_signature = 5;
case awaiting_invoicing = 6;
/**
* Optionnal labels definition.
@ -21,5 +23,7 @@ enum InvoiceStatusEnum: int
self::refused->name => "Refusé (par le client ou aucune réponse de sa part)",
self::canceled->name => "Annulé (supprimé)",
self::archived->name => "Archivé (validé et envoyé à la comptabilité)",
self::awaiting_signature->name => "En attente de signature",
self::awaiting_invoicing->name => "En attente de facturation",
];
}

View file

@ -27,7 +27,7 @@ enum TaskTypeEnum: int
* Custom added prices definition
*/
private const PRICES = [
self::web->name => 500,
self::web->name => 600,
self::seo->name => 690,
// * Linked to packages table
self::package->name => 0,

View file

@ -0,0 +1,70 @@
<?php
namespace App\Enums\Tickets;
use App\Traits\Enums\BaseEnum;
enum TicketFileTypeEnum: int
{
use BaseEnum;
case png = '.png';
case jpeg = '.jpeg';
case jpg = '.jpg';
case pdf = '.pdf';
case pptx = '.pptx';
case docx = '.docx';
case xlsx = '.xlsx';
case csv = '.csv';
case svg = '.svg';
/**
* Optionnal labels definition
*/
private const LABELS = [
self::png->name => "Fichier png",
self::jpeg->name => "Fichier jpeg",
self::jpg->name => "Fichier jpg",
self::pdf->name => "Fichier pdf",
self::pptx->name => "Fichier pptx",
self::docx->name => "Fichier docx",
self::xlsx->name => "Fichier xlsx",
self::csv->name => "Fichier csv",
self::svg->name => "Fichier svg",
];
/**
* Custom added mimes type definition
*/
private const MIMETYPE = [
self::png->name => 'image/png',
self::jpeg->name => 'image/jpeg',
self::jpg->name => 'image/jpeg',
self::pdf->name => 'application/pdf',
self::pptx->name => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
self::docx->name => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
self::xlsx->name => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
self::csv->name => 'text/csv',
self::svg->name => 'image/svg+xml',
];
/**
* Get Class
*
* @return string
*/
public function mimetypes(): string
{
return self::MIMETYPE[$this->name];
}
/**
* Get enum classes
*
* @return array<string>
*/
public static function toMimetypes(): array
{
return self::MIMETYPE;
}
}

View file

@ -14,21 +14,25 @@ enum TicketStatusEnum: int
case waiting = 4;
case waitingValidation = 5;
case recette = 6;
case production = 7;
case archived = 8;
case recetteValidated = 7;
case production = 8;
case archived = 9;
case inDev = 10;
/**
* Optionnal labels definition
*/
private const LABELS = [
self::new->name => "Nouveau",
self::estimateTodo->name => "Devis à faire",
self::takenInAccount->name => "Pris en compte",
self::estimateTodo->name => "Étude chef(s) de projet",
self::takenInAccount->name => "À planifier",
self::waiting->name => "En attente de réponse",
self::waitingValidation->name => "En attente de validation",
self::recette->name => "En recettage",
self::recetteValidated->name => "Recettage validé",
self::production->name => "En production",
self::archived->name => "Archivé",
self::inDev->name => "En cours de développement",
];
/**
@ -41,8 +45,10 @@ enum TicketStatusEnum: int
self::waiting->name => 'text-white bg-danger',
self::waitingValidation->name => 'text-warning bg-danger',
self::recette->name => 'text-primary',
self::recetteValidated->name => 'text-success',
self::production->name => 'text-success',
self::archived->name => 'text-secondary',
self::inDev->name => 'text-discovery',
];
/**

View file

@ -8,12 +8,14 @@ enum TicketTypeEnum: int
{
use BaseEnum;
case bug = 0;
case evolution = 1;
case br = 2;
case newsletter = 3;
case qrcode = 4;
case advice = 5;
case bug = 1;
case evolution = 2;
case br = 3;
case newsletter = 4;
case qrcode = 5;
case advice = 6;
case complaints = 7;
case mailing = 8;
/**
* Optionnal labels definition
@ -25,6 +27,8 @@ enum TicketTypeEnum: int
self::newsletter->name => "Demande newsletter",
self::qrcode->name => "Demande de QR Code",
self::advice->name => "Conseil - Accompagnement",
self::complaints->name => "Réclamations consommateurs",
self::mailing->name => "Demande mail en masse",
];
/**
@ -37,6 +41,8 @@ enum TicketTypeEnum: int
self::newsletter->name => "bg-warning",
self::qrcode->name => "bg-secondary",
self::advice->name => "bg-info",
self::complaints->name => "bg-dark",
self::mailing->name => "bg-discovery",
];
/**

View file

@ -1,20 +0,0 @@
<?php
namespace App\Enums\Users;
use App\Traits\Enums\BaseEnum;
enum GitlabUsersEnum: int
{
use BaseEnum;
// Each user is associated to his ID on gitlab.
case olivier = 11;
/**
* Optionnal labels definition
*/
private const LABELS = [
self::olivier->name => "Olivier LEGAT",
];
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Events;
use Domain\Models\ValueObjects\Email;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
readonly class BrevoWebhookCallReceived
{
use Dispatchable;
public function __construct(
public Email $from,
public Email $to,
public string $htmlRawContent
) {}
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('default'),
];
}
}

View file

@ -0,0 +1,34 @@
<?php
namespace App\Events;
use App\Models\Site;
use App\Models\Ticket;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class TicketCreated implements ShouldQueue
{
use Dispatchable;
use SerializesModels;
public function __construct(
public readonly Site $siteReceivingTicket,
public readonly Ticket $ticket,
public readonly string $byUserName
) {}
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('default'),
];
}
}

View file

@ -0,0 +1,58 @@
<?php
namespace App\Http\Controllers\Bo;
use App\Events\BrevoWebhookCallReceived;
use App\Http\Requests\Bo\BrevoWebhookRequest;
use Domain\Models\ValueObjects\Email;
use Psr\Log\LoggerInterface;
use Illuminate\Routing\Controller as BaseController;
use \Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
class BrevoWebhookController extends BaseController
{
public function __construct(
private readonly LoggerInterface $logger,
private readonly Dispatcher $dispatcher
) {}
public function webhookCallReceived(BrevoWebhookRequest $request): JsonResponse
{
$fromEmail = $request->getFromAddress();
$toEmail = $request->getToAddress();
$formContent = $request->getRawHtmlBody();
if (!$this->isFromLdc($fromEmail)) {
$this->logger->warning(
'Received a brevo webhook call from a non ldc email.',
[
'from' => $fromEmail,
'to' => $toEmail,
'content' => base64_encode($formContent)
]
);
return response()->json(
['ok' => false],
Response::HTTP_BAD_REQUEST
);
}
$this->dispatcher->dispatch(
new BrevoWebhookCallReceived(
from: $fromEmail,
to: $toEmail,
htmlRawContent: $formContent,
)
);
return response()->json(['ok' => true]);
}
private function isFromLdc(Email $email): bool
{
return substr(strrchr($email->value, "@"), 1) === 'ldc.fr';
}
}

View file

@ -1,29 +0,0 @@
<?php
namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use App\Models\Dutyhour;
use Illuminate\Contracts\View\View;
class DashboardController extends Controller
{
/**
* Show Home page
*
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
*/
public function index(): View
{
/**
* Get only duty hours for today or later.
*
* @var \Illuminate\Database\Eloquent\Builder $dutyhour
*/
$dutyhourModels = Dutyhour::where('date', '>', now()->modify('-1 day'))
->orderBy('date', 'asc')
->limit(10)
->get();
return view('home', compact('dutyhourModels'));
}
}

View file

@ -1,157 +0,0 @@
<?php
namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\Dutyhours\StoreDutyhourRequest;
use App\Http\Requests\Bo\Dutyhours\UpdateDutyhourRequest;
use App\Models\Dutyhour;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class DutyhourController extends Controller
{
/**
* Display a listing of the resource.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\View
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $dutyhourModels */
$dutyhourModels = Dutyhour::query();
/** @var string $search Search field */
$search = $request->search;
if ($search) {
$this->searchQuery(
$dutyhourModels,
$search,
null,
'date',
'person',
'place'
);
}
$searchFields = trans('Date, personne, lieu');
/** Sort columns with a query */
$this->sortQuery($dutyhourModels);
/** Custom pagination */
$dutyhourModels = $this->customPaginate($dutyhourModels, $request->pagination);
return view('bo.pages.dutyhours.index', compact('dutyhourModels', 'search', 'searchFields'));
}
/**
* Show the form for creating a new resource.
*
* @param \App\Models\Dutyhour $dutyhour
* @return \Illuminate\Contracts\View\View
*/
public function create(Dutyhour $dutyhour): \Illuminate\Contracts\View\View
{
return view('bo.pages.dutyhours.create', [
'dutyhourModel' => $dutyhour
]);
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\Bo\Dutyhours\StoreDutyhourRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(StoreDutyhourRequest $request): \Illuminate\Http\RedirectResponse
{
return DB::transaction(function () use ($request) {
$dutyhour = new Dutyhour();
$dutyhour->fill($request->validated());
if ($dutyhour->saveOrFail()) {
return redirect()
->route('bo.dutyhours.edit', $dutyhour)
->with('success', trans(
'crud.messages.has_been_created',
['model' => Str::singular(trans('models.classes.dutyhours'))]
));
}
return redirect()
->back()
->with('error', trans(
'crud.messages.cannot_be_created',
['model' => Str::singular(trans('models.classes.dutyhours'))]
));
});
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Dutyhour $dutyhour
* @return \Illuminate\Contracts\View\View
*/
public function edit(Dutyhour $dutyhour): \Illuminate\Contracts\View\View
{
return view('bo.pages.dutyhours.edit', [
'dutyhourModel' => $dutyhour
]);
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\Bo\Dutyhours\UpdateDutyhourRequest $request
* @param \App\Models\Dutyhour $dutyhour
* @return \Illuminate\Http\RedirectResponse
*/
public function update(UpdateDutyhourRequest $request, Dutyhour $dutyhour): \Illuminate\Http\RedirectResponse
{
return DB::transaction(function () use ($request, $dutyhour) {
$dutyhour->fill($request->validated());
if ($dutyhour->saveOrFail()) {
return redirect()
->route('bo.dutyhours.edit', $dutyhour)
->with('success', trans(
'crud.messages.has_been_updated',
['model' => Str::singular(trans('models.classes.dutyhours'))]
));
} //end if
return redirect()
->back()
->with('error', trans(
'crud.messages.cannot_be_updated',
['model' => Str::singular(trans('models.classes.dutyhours'))]
));
});
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Dutyhour $dutyhour
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(Dutyhour $dutyhour): \Illuminate\Http\RedirectResponse
{
return DB::transaction(function () use ($dutyhour) {
if ($dutyhour->deleteOrFail()) {
return redirect()
->route('bo.dutyhours.index')
->with('success', trans(
'crud.messages.has_been_deleted',
['model' => Str::singular(trans('models.classes.dutyhours'))]
));
}
return redirect()
->back()
->with('error', trans(
':crud.messages.cannot_be_deleted',
['model' => Str::singular(trans('models.classes.dutyhours'))]
));
});
}
}

View file

@ -25,12 +25,27 @@ class InvoiceController extends Controller
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
// If no sorting is requested, apply the default orderByDesc.
/** @var \Illuminate\Database\Eloquent\Builder $invoiceModels */
$invoiceModels = Invoice::query();
$status = intval($request->status);
$invoiceModels = $invoiceModels->when($status, function ($query) use ($status) {
$query->where('status', $status);
});
$invoiceModels = (!request()->query('sort_col') && !request()->query('sort_way'))
? Invoice::query()->orderByDesc('created_at')
: Invoice::query();
$status = intval($request->status);
switch ($status) {
case InvoiceStatusEnum::awaiting_signature->value:
$invoiceModels->whereNotNull('sent_client_date')->whereNull('signed_date');
break;
case InvoiceStatusEnum::awaiting_invoicing->value:
$invoiceModels->whereNotNull('sent_client_date')->whereNotNull('signed_date')->whereNull('sent_accounting_date');
break;
default:
if ($status !== 0) {
$invoiceModels->where('status', $status);
}
break;
}
/** @var string $search Search field */
$search = $request->search;
@ -41,9 +56,11 @@ class InvoiceController extends Controller
null,
'firstname',
'lastname',
'ref',
'site_id',
);
}
$searchFields = trans('Nom, Prénom');
$searchFields = trans('Nom, Prénom, Référence, Site');
/** Sort columns with a query */
$this->sortQuery($invoiceModels);
@ -73,7 +90,7 @@ class InvoiceController extends Controller
*/
public function create(Invoice $invoice): \Illuminate\Contracts\View\View
{
$packageModels = Package::get();
$packageModels = Package::where('published', true)->get();
$taskRowModel = Invoice::getTaskStructure();
$siteModels = Site::orderBy('name', 'ASC')->get();
$companyModels = Company::get();
@ -180,7 +197,10 @@ class InvoiceController extends Controller
return $invoice->generateInvoice()
->stream(Str::slug(trans('Devis :appname :date - ref :ref', [
'appname' => config('app.name'),
'date' => $invoice->created_at->isoFormat('YYYY-MM-DD'),
'date' =>
$invoice->created_at !== $invoice->updated_at ?
$invoice->updated_at->isoFormat('YYYY-MM-DD') :
$invoice->created_at->isoFormat('YYYY-MM-DD'),
'ref' => $invoice->ref,
])) . '.pdf');
}
@ -200,7 +220,7 @@ class InvoiceController extends Controller
{
$model = $request->targetModel;
return DB::transaction(function () use ($model) {
$models = $model::orderBy('name', 'ASC')->paginate(12);
$models = $model::query()->orderBy('name', 'ASC')->paginate(12);
return \response()->json($models ?? 500);
});
}

View file

@ -23,6 +23,15 @@ class PackageController extends Controller
/** @var \Illuminate\Database\Eloquent\Builder $packageModels */
$packageModels = Package::query();
$status = $request->status;
if ($status === null) {
$packageModels->where('published', true);
} elseif ($status === '0') {
$packageModels->where('published', false);
} elseif ($status === '1') {
$packageModels->where('published', true);
}
/** @var string $search Search field */
$search = $request->search;
if ($search) {
@ -42,7 +51,7 @@ class PackageController extends Controller
/** Custom pagination */
$packageModels = $this->customPaginate($packageModels, $request->pagination);
return view('bo.pages.packages.index', compact('packageModels', 'search', 'searchFields'));
return view('bo.pages.packages.index', compact('packageModels', 'search', 'searchFields', 'status'));
}
/**
@ -153,4 +162,16 @@ class PackageController extends Controller
));
});
}
/**
* Change model published.
*
* @param \App\Models\Package $package
* @return \Illuminate\Http\RedirectResponse
*/
public function changePublished(Package $package)
{
$package->update(['published' => !$package->getOriginal('published')]);
return redirect()->back()->with('success', trans(__('crud.messages.publish_status_saved')));
}
}

View file

@ -1,193 +0,0 @@
<?php
namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\Projects\StoreProjectRequest;
use App\Http\Requests\Bo\Projects\UpdateProjectRequest;
use App\Lib\Helpers\ToolboxHelper;
use App\Models\Project;
use App\Models\Site;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
class ProjectController extends Controller
{
/**
* Display a listing of the resource.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Contracts\View\View
*/
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \Illuminate\Database\Eloquent\Builder $projectModels */
$projectModels = Project::query();
/** @var string $search Search field */
$search = $request->search;
if ($search) {
$this->searchQuery(
$projectModels,
$search,
null,
'name',
);
}
$searchFields = trans('Nom');
/** Sort columns with a query */
$this->sortQuery($projectModels);
/** Custom pagination */
$projectModels = $this->customPaginate($projectModels, $request->pagination);
return view('bo.pages.projects.index', compact('projectModels', 'search', 'searchFields'));
}
/**
* Crud show view
*
* @param \App\Models\Project $project
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
*/
public function show(Project $project)
{
return view('bo.pages.projects.show', [
'projectModel' => $project
]);
}
/**
* Show the form for creating a new resource.
*
* @param \App\Models\Project $project
* @return \Illuminate\Contracts\View\View
*/
public function create(Project $project): \Illuminate\Contracts\View\View
{
$siteModels = Site::orderBy('name', 'ASC')->get();
return view('bo.pages.projects.create', [
'projectModel' => $project,
'siteModels' => $siteModels
]);
}
/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\Bo\Projects\StoreProjectRequest $request
* @return \Illuminate\Http\RedirectResponse
*/
public function store(StoreProjectRequest $request): \Illuminate\Http\RedirectResponse
{
return DB::transaction(function () use ($request) {
$project = new Project();
$project->fill($request->validated());
if ($project->saveOrFail()) {
return redirect()
->route('bo.projects.edit', $project)
->with('success', trans(
'crud.messages.has_been_created',
['model' => Str::singular(trans('models.classes.projects'))]
));
}
return redirect()
->back()
->with('error', trans(
'crud.messages.cannot_be_created',
['model' => Str::singular(trans('models.classes.projects'))]
));
});
}
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Project $project
* @return \Illuminate\Contracts\View\View
*/
public function edit(Project $project): \Illuminate\Contracts\View\View
{
$siteModels = Site::orderBy('name', 'ASC')->get();
return view('bo.pages.projects.edit', [
'projectModel' => $project,
'siteModels' => $siteModels
]);
}
/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\Bo\Projects\UpdateProjectRequest $request
* @param \App\Models\Project $project
* @return \Illuminate\Http\RedirectResponse
*/
public function update(UpdateProjectRequest $request, Project $project): \Illuminate\Http\RedirectResponse
{
return DB::transaction(function () use ($request, $project) {
$project->fill($request->validated());
if ($project->saveOrFail()) {
return redirect()
->route('bo.projects.edit', $project)
->with('success', trans(
'crud.messages.has_been_updated',
['model' => Str::singular(trans('models.classes.projects'))]
));
} //end if
return redirect()
->back()
->with('error', trans(
'crud.messages.cannot_be_updated',
['model' => Str::singular(trans('models.classes.projects'))]
));
});
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Project $project
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(Project $project): \Illuminate\Http\RedirectResponse
{
return DB::transaction(function () use ($project) {
if ($project->deleteOrFail()) {
return redirect()
->route('bo.projects.index')
->with('success', trans(
'crud.messages.has_been_deleted',
['model' => Str::singular(trans('models.classes.projects'))]
));
}
return redirect()
->back()
->with('error', trans(
':crud.messages.cannot_be_deleted',
['model' => Str::singular(trans('models.classes.projects'))]
));
});
}
/**
* Get a paginate resource.
*
* @param \Illuminate\Http\Request $request
* @return Illuminate\Http\JsonResponse
*/
public function jsonPaginate(Request $request): \Illuminate\Http\JsonResponse
{
return DB::transaction(function () use ($request) {
$model = $request->targetModel;
$search = $request->search;
$models = $model::where("name", "LIKE", "%{$search}%")->orderBy("name", "ASC");
return ToolboxHelper::jsonPaginate($this->customPaginate($models, $request->pagination));
});
}
}

View file

@ -9,6 +9,7 @@ use App\Lib\Helpers\ToolboxHelper;
use App\Models\Site;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
@ -23,15 +24,15 @@ class SiteController extends Controller
public function index(Request $request): \Illuminate\Contracts\View\View
{
/** @var \App\Models\User $user */
$user = \auth()->user();
$user = Auth::user();
if ($user->isAdmin()) {
/** @var \Illuminate\Database\Eloquent\Builder $siteModels */
$siteModels = Site::query();
$siteModels = Site::query()->with(['invoices', 'tickets']);
} else {
/** @var \Illuminate\Database\Eloquent\Builder $siteModels */
$siteModels = Site::whereHas('users', function (\Illuminate\Database\Eloquent\Builder $query) use ($user) {
$query->where('id', $user->id);
$query->where('id', $user->id)->with(['invoices', 'tickets']);
});
}

View file

@ -2,41 +2,48 @@
namespace App\Http\Controllers\Bo;
use App\Enums\Tickets\TicketStatusEnum;
use App\Enums\Tickets\TicketTypeEnum;
use App\Enums\Users\GitlabUsersEnum;
use App\Models\Site;
use App\Models\User;
use App\Models\Ticket;
use App\Mail\NewTicket;
use App\Models\Message;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use App\Jobs\UpdateIssueLabels;
use App\Lib\Helpers\ToolboxHelper;
use Illuminate\Support\Facades\DB;
use App\Events\NotifySubscriptions;
use App\Events\TicketStatusChanged;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\AssignTicketToUserRequest;
use App\Http\Requests\Bo\ChangeTicketStatus;
use App\Http\Requests\Bo\CreateMessage;
use App\Http\Requests\Bo\LinkTicket;
use Illuminate\Support\Facades\Mail;
use App\Enums\Tickets\TicketTypeEnum;
use App\Http\Requests\Bo\SortTickets;
use App\Http\Requests\Bo\StoreTicket;
use App\Http\Requests\Bo\UpdateMessage;
use App\Http\Requests\Bo\UpdateTicket;
use App\Lib\Helpers\FileStorageHelper;
use App\Lib\Helpers\ToolboxHelper;
use App\Mail\NewTicket;
use App\Models\Message;
use App\Models\Site;
use App\Models\Ticket;
use App\Models\User;
use App\Enums\Tickets\TicketStatusEnum;
use App\Events\TicketCreated;
use App\Http\Requests\Bo\CreateMessage;
use App\Http\Requests\Bo\UpdateMessage;
use Illuminate\Support\Facades\Session;
use GrahamCampbell\GitLab\Facades\GitLab;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str;
use App\Http\Requests\Bo\ChangeTicketStatus;
use App\Http\Requests\Bo\UpdateChangeOrderRequest;
use App\Http\Requests\Bo\AssignTicketToUserRequest;
use App\Http\Requests\Bo\UpdateTicketPriorityRequest;
use Illuminate\Contracts\Events\Dispatcher;
class TicketController extends Controller
{
/**
* TicketController
*/
public function __construct()
{
public function __construct(
public readonly Dispatcher $dispatcher
) {
parent::__construct();
$this->authorizeResource(Ticket::class, 'ticket');
}
@ -74,7 +81,6 @@ class TicketController extends Controller
}));
} //end if
/** @var \App\Models\User */
$user = auth()->user();
$tickets = Ticket::with(['site', 'labels']);
@ -95,15 +101,30 @@ class TicketController extends Controller
TicketStatusEnum::archived
);
if (!$user->isAdmin() && $user->sites->count() === 1) {
$request->merge([
'pr' => $user->sites->first()->id,
]);
}
$tickets = $this->filterTickets($tickets, $request);
$tickets = $this->searchTicket($tickets, $request);
/** Sort columns with a query */
$this->sortQuery($tickets);
/** Custom pagination */
$tickets = $this->customPaginate($tickets, $request->pagination);
$sites = Site::select('id', 'name')->orderBy('name')->get();
$status = TicketStatusEnum::cases();
$status = Arr::sort(TicketStatusEnum::cases(), function (TicketStatusEnum $value) {
return $value->label();
});
$types = Arr::sort(TicketTypeEnum::cases(), function (TicketTypeEnum $value) {
return $value->label();
});
return view('bo.pages.tickets.index', compact('tickets', 'sites', 'status'));
return view('bo.pages.tickets.index', compact('tickets', 'sites', 'status', 'types'));
}
/**
@ -135,7 +156,11 @@ class TicketController extends Controller
$messages = $ticket->messages()->orderBy('created_at', 'DESC')->get();
$isSubscribed = (bool)$ticket->subscriptions()->where('user_id', $user->id)->count();
return view('bo.pages.tickets.show', compact('ticket', 'messages', 'isSubscribed'));
return view('bo.pages.tickets.show', [
'ticket' => $ticket,
'messages' => $messages,
'isSubscribed' => $isSubscribed
]);
}
/**
@ -178,19 +203,20 @@ class TicketController extends Controller
$ticket = new Ticket($request->validated());
/** @var \Illuminate\Http\UploadedFile|null */
$fileTicket = $request->file_ticket;
/** @var \Illuminate\Http\UploadedFile|null */
$fileTicket2 = $request->file_ticket2;
if ($fileTicket) {
$ticket->file = FileStorageHelper::storeFile($ticket, $fileTicket);
}
if ($fileTicket2) {
$ticket->file2 = FileStorageHelper::storeFile($ticket, $fileTicket2);
/** @var array<\Illuminate\Http\UploadedFile> */
$fileTickets = $request->file_tickets ?? [];
if (count($fileTickets) > 0) {
foreach ($fileTickets as $key => $file) {
if ($key === 0) {
$ticket->file = FileStorageHelper::storeFile($ticket, $file);
} else {
$fileNumber = 'file' . $key + 1;
$ticket->$fileNumber = FileStorageHelper::storeFile($ticket, $file);
}
}
}
$ticket->user()->associate(auth()->user());
$ticket->user()->associate($user);
$ticket->site()->associate($site);
$ticket->saveOrFail();
@ -200,11 +226,11 @@ class TicketController extends Controller
$user->subscriptions()->toggle($ticket->id);
if (config('mail.MAIL_ADMIN')) {
Mail::to(config('mail.MAIL_ADMIN'))->send(new NewTicket($ticket));
} else {
throw new \ErrorException('Missing MAIL_ADMIN in .env');
}
$this->dispatcher->dispatch(new TicketCreated(
siteReceivingTicket: $site,
ticket: $ticket,
byUserName: $user->name
));
return redirect()->route('bo.ticket.show', $ticket)
->with('success', trans('Ticket enregistré !'));
@ -252,18 +278,18 @@ class TicketController extends Controller
/** @var \App\Models\Site */
$site = Site::findOrFail($request->site_id);
/** @var \Illuminate\Http\UploadedFile|null */
$fileTicket = $request->file_ticket;
/** @var \Illuminate\Http\UploadedFile|null */
$fileTicket2 = $request->file_ticket2;
if ($fileTicket) {
$ticket->file = FileStorageHelper::storeFile($ticket, $fileTicket);
/** @var null|array<\Illuminate\Http\UploadedFile> */
$fileTickets = $request->file_tickets;
if (isset($fileTickets) && count($fileTickets) > 0) {
foreach ($fileTickets as $key => $file) {
if ($key === 0) {
$ticket->file = FileStorageHelper::storeFile($ticket, $file);
} else {
$fileNumber = 'file' . $key + 1;
$ticket->$fileNumber = FileStorageHelper::storeFile($ticket, $file);
}
}
}
if ($fileTicket2) {
$ticket->file2 = FileStorageHelper::storeFile($ticket, $fileTicket2);
}
$ticket->labels()->sync($request->labels);
@ -290,6 +316,10 @@ class TicketController extends Controller
*/
public function changeStatus(ChangeTicketStatus $request, Ticket $ticket)
{
if ($ticket->gitlab_issue) {
\dispatch(new UpdateIssueLabels($ticket, $request->status));
}
$ticket->fill($request->validated());
$ticket->saveOrFail();
@ -309,32 +339,39 @@ class TicketController extends Controller
try {
return DB::transaction(function () use ($request, $ticket) {
/** @var \Illuminate\Http\UploadedFile|null */
$fileMessage = $request->file_message;
$message = new Message($request->validated());
$filesMessage = $request->file_messages;
$message = new Message($request->validated());
$message->user()->associate(auth()->user());
$message->ticket()->associate($ticket);
/** @var \App\Models\User */
$user = auth()->user();
// Subscribe to ticket.
if ($request->subscribe) {
if (!$user->subscriptions()->find($ticket->id)) {
$user->subscriptions()->attach($ticket->id);
}
} elseif ($user->subscriptions()->find($ticket->id)) {
$user->subscriptions()->syncWithoutDetaching([$ticket->id]);
} else {
$user->subscriptions()->detach($ticket->id);
}
// Store files if any.
if (isset($filesMessage) and $filesMessage) {
foreach ($filesMessage as $key => $singleFile) {
if ($key === 0) {
$message->file = FileStorageHelper::storeFile($message, $singleFile);
$message->saveOrFail();
} else {
$fileNumber = 'file' . $key + 1;
$message->$fileNumber = FileStorageHelper::storeFile($message, $singleFile);
$message->saveOrFail();
}
}
}
$message->saveOrFail();
if ($fileMessage) {
$message->file = FileStorageHelper::storeFile($message, $fileMessage);
$message->saveOrFail();
}
return back()
->with('success', trans('Votre message à été ajouté'));
});
}, 5);
} catch (\ErrorException $e) {
report($e);
Session::flash('error', trans('Une erreur est survenue'));
@ -470,6 +507,48 @@ class TicketController extends Controller
return back()->with('info', trans('Le ticket n\'est plus assigné à personne'));
}
/**
* Link two tickets.
*
* @param LinkTicket $request
* @param Ticket $ticket
*
* @return \Illuminate\Http\RedirectResponse
*/
public function linkTicket(LinkTicket $request, Ticket $ticket)
{
$linkedTicket = Ticket::findOrFail($request->validated())->first();
if ($ticket->site_id !== $linkedTicket->site_id) {
return back()->with('error', trans('Le ticket que vous avez renseigné ne fait pas partie du même site.'));
}
if (!$ticket->linkedTickets()->where('linked_ticket_id', $linkedTicket->id)->exists()) {
$ticket->linkedTickets()->attach($linkedTicket->id);
$linkedTicket->linkedTickets()->attach($ticket->id);
return back()->with('success', trans('Les tickets ont été liés avec succès.'));
}
return back()->with('error', trans('Les tickets sont déjà liés ensemble.'));
}
/**
* Unlink two tickets.
*
* @param Ticket $ticket
* @param Ticket $linkedTicket
*
* @return \Illuminate\Http\RedirectResponse
*/
public function unlinkTicket(Ticket $ticket, Ticket $linkedTicket)
{
$ticket->linkedTickets()->detach($linkedTicket->id);
$linkedTicket->linkedTickets()->detach($ticket->id);
return back()->with('warning', trans('Le lien entre les tickets à été supprimé.'));
}
// * PRIVATES
/**
@ -487,8 +566,10 @@ class TicketController extends Controller
Session::remove('tickets.ass');
Session::remove('tickets.st');
Session::remove('tickets.pr');
Session::remove('tickets.ty');
Session::remove('tickets.sort_col');
Session::remove('tickets.sort_way');
Session::remove('tickets.or');
Session::remove('tickets.search');
}
if ($request->assr) {
@ -500,21 +581,43 @@ class TicketController extends Controller
if ($request->sts) {
Session::remove('tickets.st');
}
if ($request->tys) {
Session::remove('tickets.ty');
}
if ($request->sort_col) {
Session::put('tickets.sort_col', $request->sort_col);
}
if ($request->sort_way) {
Session::put('tickets.sort_way', $request->sort_way);
}
if ($request->ord) {
Session::remove('tickets.or');
}
if ($request->pr) {
Session::put('tickets.pr', $request->pr);
}
if ($request->st) {
Session::put('tickets.st', $request->st);
}
if ($request->ty) {
Session::put('tickets.ty', $request->ty);
}
if ($request->ass) {
Session::put('tickets.ass', $request->ass);
}
if (Session::has('tickets.or')) {
Session::remove('tickets.ass');
Session::remove('tickets.st');
Session::remove('tickets.ty');
Session::remove('tickets.sort_col');
Session::remove('tickets.sort_way');
Session::remove('tickets.search');
}
if ($request->or && Session::has('tickets.pr')) {
Session::put('tickets.or', $request->or);
}
Session::save();
if (Session::has('tickets.pr')) {
@ -531,12 +634,24 @@ class TicketController extends Controller
$tickets->where('status', Session::get('tickets.st'));
}
if (Session::has('tickets.ty')) {
$tickets->where('type', Session::get('tickets.ty'));
}
if (Session::has('tickets.or')) {
$tickets->orderBy('order', 'ASC');
}
if (
Session::has('tickets.sort_col') and
Session::has('tickets.sort_way') and
in_array(Session::get('tickets.sort_col'), [
'id', 'site_id', 'created_at', 'created_by',
'type', 'status', 'assigned_to'
'type',
'title',
'assigned_to',
'date_mep',
'created_at',
'created_by'
])
) {
$tickets->orderBy(
@ -546,6 +661,7 @@ class TicketController extends Controller
} else {
$tickets->orderBy('last_activity', 'DESC');
}
return $tickets;
}
@ -595,7 +711,7 @@ class TicketController extends Controller
});
} //end foreach
} //end if
}, 'text', 'file', 'file2');
}, 'text', 'title', 'file', 'file2', 'file3', 'file4', 'file5');
}
/**
@ -636,33 +752,54 @@ class TicketController extends Controller
*/
public function createGitlabIssue(Ticket $ticket)
{
$userGitlabId = auth()->user()->gitlab_id;
$gitlabRepoId = $ticket->site->gitlab_project_id;
$description = \sprintf("%s<br>", $ticket->text);
$cLabel = match ($ticket->type) {
TicketTypeEnum::bug => 'c-bug',
TicketTypeEnum::evolution => 'c-feature',
if (GitLab::projects()->show($gitlabRepoId)['archived']) {
return back()->with('error', \trans("Ce projet GitLab est archivé et ne peut pas être utilisé."));
}
$description = \sprintf("%s<br>", $ticket->text);
$cLabel = match ($ticket->type) {
TicketTypeEnum::bug => 'c-bug,g-to-dispatch',
TicketTypeEnum::evolution,
TicketTypeEnum::mailing => 'c-feature',
TicketTypeEnum::newsletter => 'c-feature,g-to-estimate',
};
$assigneeId = match ($ticket->type) {
TicketTypeEnum::bug => $userGitlabId,
TicketTypeEnum::evolution,
TicketTypeEnum::mailing,
TicketTypeEnum::newsletter => $ticket->site->projectManager?->gitlab_id
};
try {
if (!\is_null($ticket->file)) {
$uploadedFile = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file);
$description .= $this->formatGitlabFiles($ticket, $uploadedFile, 1);
foreach ($ticket->getFiles() as $key => $file) {
if (!\is_null($file)) {
$uploadedFile = GitLab::projects()->uploadFile($gitlabRepoId, $file);
$description .= $this->formatGitlabFiles($ticket, $uploadedFile, $key + 1);
}
}
if (!\is_null($ticket->file2)) {
$uploadedFile2 = GitLab::projects()->uploadFile($gitlabRepoId, $ticket->file2);
$description .= $this->formatGitlabFiles($ticket, $uploadedFile2, 2);
}
$issue = GitLab::issues()->create($gitlabRepoId, [
'title' => 'ts-' . $ticket->id,
$data = [
'title' => sprintf(
'ts-%s : %s',
$ticket->id,
$ticket->title
),
'description' => $description,
'labels' => \implode(",", [
'c-support',
$cLabel
]),
'assignee_id' => GitlabUsersEnum::olivier,
]);
];
if ($assigneeId) {
$data['assignee_id'] = $assigneeId;
}
$issue = GitLab::issues()->create($gitlabRepoId, $data);
} catch (\Exception $e) {
\report($e);
return back()->with('error', \trans("Une erreur est survenue"));
@ -690,7 +827,7 @@ class TicketController extends Controller
*/
private function formatGitlabFiles(Ticket $ticket, array $uploadedFile, int $fileNb)
{
if (Str::endsWith($ticket->file, ['jpg', 'png', 'jpeg'])) {
if (Str::endsWith($ticket->file, ['jpg', 'png', 'jpeg', 'pptx', 'docx', 'xslx', 'csv', 'svg'])) {
$file = \sprintf(
"![Fichier joint %d](%s)",
$fileNb,
@ -705,4 +842,92 @@ class TicketController extends Controller
}
return \sprintf("<br><br> Fichier %d : <br>%s<br>", $fileNb, $file);
}
/**
* Change order.
*
* @param \App\Http\Requests\Bo\UpdateChangeOrderRequest $request
* @param mixed ...$params
* @return \Illuminate\Http\RedirectResponse
* @throws \RuntimeException Si le nom du parametre de la route ne correspond pas au params utilisé.
*/
public function changeOrder(UpdateChangeOrderRequest $request, mixed ...$params): \Illuminate\Http\RedirectResponse
{
$paramNames = collect(request()->route()->parameterNames);
$className = Str::of($paramNames->get($paramNames->count() - 2))->lower()->studly();
$className = "\\App\\Models\\{$className}";
$model = Arr::get($params, $paramNames->count() - 2);
if (!class_exists($className)) {
throw new \RuntimeException("The {$className} class doesn't exist.");
}
if (!\is_object($model)) {
throw new \RuntimeException("The second last param isn't an object.");
}
if (get_class($model) !== (string)Str::of($className)->replaceStart('\\', '')) {
throw new \RuntimeException("The {$className} doesn't match second last binded param.");
}
/** @var \Illuminate\Database\Eloquent\Model|null */
$model = $className::query()->where($model->getRouteKeyName(), $model->getRouteKey())->first();
if (!$model) {
return back()->with('error', trans('crud.messages.order_not_changed'));
}
return DB::transaction(function () use ($request, $className, $model) {
/** @var \Illuminate\Support\Collection $models */
$models = $className::query()
->orderBy('order', 'ASC')
->where('site_id', $model->site_id)
->where('status', '!=', TicketStatusEnum::archived)
->where('id', '!=', $model->getKey())
->where('order', $request->direction ? '<' : '>', $model->order)
->get();
/** @var \Illuminate\Database\Eloquent\Model|null $tmp */
$tmp = $request->direction ? $models->last() : $models->first();
if (!$tmp) {
return back()->with('error', trans('crud.messages.order_not_changed'));
}
$newOrder = $tmp->getOriginal('order');
$tmp->update(['order' => $model->getOriginal('order')]);
$model->update(['order' => $newOrder]);
return redirect()->back()->with('success', trans('crud.messages.order_changed'));
});
}
/**
* Update ticket priority.
*
* @param UpdateTicketPriorityRequest $request
* @param Ticket $ticket
* @return void
*/
public function changePriority(UpdateTicketPriorityRequest $request, Ticket $ticket)
{
$newPriority = $request->validated('priority');
return DB::transaction(function () use ($ticket, $newPriority) {
// Update all tickets who will be moved with this priority update.
$request = Ticket::query()
->where('site_id', $ticket->site_id)
->whereNot('status', TicketStatusEnum::archived)
->whereNot('id', $ticket->id)
->whereBetween('order', [min($ticket->order, $newPriority), max($ticket->order, $newPriority)]);
$ticket->order < $newPriority ? $request->decrement('order', 1) : $request->increment('order', 1);
// Update the ticket.
$ticket->order = $newPriority;
if (!$ticket->saveOrFail()) {
return back()->with('error', trans('crud.messages.order_not_changed'));
};
return redirect()->back()->with('success', trans('crud.messages.order_changed'));
});
}
}

View file

@ -2,15 +2,16 @@
namespace App\Http\Controllers\Bo;
use App\Http\Controllers\Bo\Auth\ForgotPasswordController;
use App\Models\Site;
use App\Models\User;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\Users\StoreUserRequest;
use App\Http\Requests\Bo\Users\UpdateUserRequest;
use App\Models\Site;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use App\Http\Controllers\Bo\Auth\ForgotPasswordController;
use App\Http\Requests\Bo\Users\FavouriteSiteRequest;
class UserController extends Controller
{
@ -72,8 +73,9 @@ class UserController extends Controller
public function store(StoreUserRequest $request): \Illuminate\Http\RedirectResponse
{
return DB::transaction(function () use ($request) {
$user = new User();
$user = User::query()->onlyTrashed()->where('email', $request->validated('email'))->first() ?? new User();
$user->fill($request->safe()->except('sites'));
$user->deleted_at = null;
if ($user->saveOrFail()) {
$user->sites()->attach(collect($request->validated('sites'))->pluck('id'));
@ -170,9 +172,35 @@ class UserController extends Controller
*
* @return \Illuminate\Contracts\View\View
*/
public function passwordReset(): \Illuminate\Contracts\View\View
public function settings(): \Illuminate\Contracts\View\View
{
return view('bo.pages.users.passwordReset');
return view('bo.pages.users.settings');
}
/**
* Favourite site submit
*
* @param \App\Http\Requests\Bo\Users\FavouriteSiteRequest $request
*
* @return \Illuminate\Http\RedirectResponse
*/
public function favouriteSiteSubmit(FavouriteSiteRequest $request): \Illuminate\Http\RedirectResponse
{
/** @var \App\Models\User */
$user = auth()->user();
try {
$user->favourite_site_id = $request->favourite_site_id;
$user->saveOrFail();
return redirect()->back()->with("success", trans('crud.messages.favourite_site_changed'));
} catch (\Exception $e) {
\report($e);
return redirect()->back()->with('error', trans('crud.messages.favourite_site_not_changed'));
} catch (\Throwable $e) {
\report($e);
return redirect()->back()->with('error', trans('crud.messages.favourite_site_not_changed'));
}
}
/**

View file

@ -15,6 +15,7 @@ use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Str;
class Controller extends BaseController
{
@ -117,28 +118,80 @@ class Controller extends BaseController
* @param array $fields
* @return \Illuminate\Database\Eloquent\Builder
*/
private function searchOnFields(Builder $query, string $search, array $fields): Builder
{
private function searchOnFields(
Builder $query,
string $search,
array $fields
): \Illuminate\Database\Eloquent\Builder {
$table = $query->getModel()->getTable();
foreach ($fields as $f) {
$f = str_replace('?', '\?', $f);
if (is_array($f)) {
foreach ($fields as $field) {
$field = str_replace('?', '\?', $field);
if (is_array($field)) {
$query->orWhereRaw(
sprintf("UPPER(CONCAT(%s)) LIKE UPPER(?)", collect($f)->map(function ($q) use ($table) {
sprintf("UPPER(CONCAT(%s)) LIKE UPPER(?)", collect($field)->map(function ($q) use ($table) {
return "`$table`.`$q`";
})->implode(', \' \', ')),
['%' . filter_var($search, FILTER_SANITIZE_STRING) . '%']
);
} else {
$query->orWhereRaw(
"UPPER(`$table`.`$f`) LIKE UPPER(?)",
['%' . filter_var($search, FILTER_SANITIZE_STRING) . '%']
['%' . htmlspecialchars($search) . '%']
);
return $query;
}
}
// Get models woth enum's label.
if (is_array($this->getSearchValue($query, $search, $field))) {
foreach ($this->getSearchValue($query, $search, $field) as $array) {
$query->orWhereRaw(
"UPPER(`$table`.`$field`) LIKE UPPER(?)",
['%' . htmlspecialchars($array->value) . '%']
);
}
return $query;
}
// Get models with relation's name/label.
if (Str::endsWith($field, '_id')) {
$query->orWhereHas(Str::remove('_id', $field), function ($queryRelation) use ($field, $search) {
if (Schema::hasColumn(Str::remove('_id', $field) . 's', 'name')) {
$queryRelation->where('name', 'like', '%' . $search . '%');
} elseif (Schema::hasColumn(Str::remove('_id', $field) . 's', 'label')) {
$queryRelation->where('label', 'like', '%' . $search . '%');
}
});
return $query;
}
$query->orWhereRaw(
"UPPER(`$table`.`$field`) LIKE UPPER(?)",
['%' . htmlspecialchars($this->getSearchValue($query, $search, $field)) . '%']
);
} //end foreach
return $query;
}
/**
* Get the search value (on string or Enum).
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $search
* @param string $field
* @return string|array
*/
protected function getSearchValue(Builder $query, string $search, string $field): string|array
{
$cast = $query->getModel()->getCasts()[$field] ?? null;
if (
count($query->getModel()->getCasts()) and // Check if the model has casts.
$cast and // Check if there is cast about specific field.
enum_exists($cast) // Check if the cast is an enum.
) {
/** @var \App\Traits\Enums $cast */
// @phpstan-ignore-next-line
$cases = collect($cast::toArray());
$enum = $cases->filter(function ($item) use ($search) {
return preg_match('/' . Str::lower($search) . '/', Str::lower($item->label));
});
return $enum->toArray();
} else {
return $search;
}
}
/**
* Sort columns with a query
*
@ -163,17 +216,13 @@ class Controller extends BaseController
Session::remove("$rName.sort_col");
Session::remove("$rName.sort_way");
}
if (request()->sort_col and request()->sort_way and Schema::hasColumn($table, request()->sort_col)) {
if (
!isset($ignore) or
(isset($ignore) and !in_array(request()->sort_col, $ignore))
) {
$query = $query->orderBy(\sprintf("$table.%s", request()->sort_col), request()->sort_way);
}
} elseif (Schema::hasColumn($table, 'order')) {
$query = $query->orderBy('order', 'ASC');
Session::put("$rName.sort_col", 'order');
Session::put("$rName.sort_way", 'asc');
if (
request()->sort_col &&
request()->sort_way &&
Schema::hasColumn($table, request()->sort_col) &&
(!isset($ignore) || (isset($ignore) && !in_array(request()->sort_col, $ignore)))
) {
$query = $query->orderBy("$table." . request()->sort_col, request()->sort_way);
}
return $query;
}

View file

@ -27,8 +27,8 @@ class RedirectIfAuthenticated
if (Auth::guard($guard)->check()) {
switch ($guard) {
case 'backend':
if (!$request->routeIs('bo.*')) {
continue;
if (!$request->routeIs('bo.*') && !$request->routeIs('login')) {
continue 2;
}
return \redirect()->route('bo.dashboard');
default:

View file

@ -12,6 +12,7 @@ class VerifyCsrfToken extends Middleware
* @var array<int, string>
*/
protected $except = [
'/csp-report'
'/csp-report',
'/brevo-in'
];
}

View file

@ -29,7 +29,7 @@ class AssignTicketToUserRequest extends FormRequest
return [
'assign' => [
'nullable', 'exists:users,id',
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
function ($attribute, $value, $fail) {
/** @var \App\Models\User $user */
if ($user = User::whereId($value)->first() and !$user->isAdmin()) {

View file

@ -0,0 +1,50 @@
<?php
namespace App\Http\Requests\Bo;
use Domain\Models\ValueObjects\Email;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Config;
class BrevoWebhookRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
public function getFromAddress(): Email
{
return new Email($this->string('items.0.From.Address'));
}
public function getToAddress(): Email
{
return new Email((string) $this->input('items.0.To.0.Address'));
}
public function getRawHtmlBody(): string
{
return $this->string('items.0.RawHtmlBody');
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$expectedFormAddress = Config::string('mail.brevo_webook.expected_from_address');
return [
'items' => ['required', 'array', 'min:1'],
'items.0.From.Address' => ['required', 'email:rfc,spoof'],
'items.0.To.*.Address' => ['required', 'email:rfc,spoof', "in:{$expectedFormAddress}"],
'items.0.RawHtmlBody' => ['required', 'string', 'min:10'],
];
}
}

View file

@ -29,7 +29,7 @@ class ChangeTicketStatus extends FormRequest
return [
'status' => [
'required',
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
function ($attribute, $value, $fail) {
if (!in_array($value, TicketStatusEnum::toValues())) {
$fail(__('Veuillez choisir entre :values', [

View file

@ -37,9 +37,11 @@ class CreateMessage extends FormRequest
*/
protected function prepareForValidation()
{
/** @var \App\Models\User */
$user = auth()->user();
$this->merge([
'subscribe' => $this->subscribe ? true : false,
'type' => $this->is_private ? MessageTypeEnum::private->value : MessageTypeEnum::public->value
'type' => $this->is_private ? MessageTypeEnum::private->value : MessageTypeEnum::public->value
]);
}
@ -53,13 +55,24 @@ class CreateMessage extends FormRequest
/** @var \App\Models\User */
$user = auth()->user();
return [
'subscribe' => 'required|boolean',
'message' => 'required|min:' . ($user->isAdmin() ? '5' : '20'),
'file_message' => 'sometimes|mimes:jpeg,jpg,png,pdf|max:2048',
'type' => [
'subscribe' => 'required|boolean',
'message' => [
'required',
new Enum(MessageTypeEnum::class)
]
'min:' . ($user->isAdmin() ? '5' : '20'),
function ($attribute, $value, $fail) {
$forbidden = ['merci de', 'merci de'];
foreach ($forbidden as $word) {
if (stripos(strtolower($value), $word) !== false) {
$fail(
"Le champs 'Message' contient la chaine de caractère non autorisée suivante : $word"
);
}
}
},
],
'file_messages' => 'sometimes|array',
'file_messages.*' => 'mimes:pptx,docx,xlsx,csv,txt,jpeg,jpg,png,pdf,svg|max:2048',
'type' => ['required', new Enum(MessageTypeEnum::class)]
];
}
}

View file

@ -33,14 +33,18 @@ class CreateEstimateRequest extends FormRequest
$ticket = $this->ticket;
return [
'amount' => [
'required', 'numeric', 'gt:0', function ($attribute, $value, $fail) {
if ((\floatval($value) * 1000) % 125 !== 0) {
$fail("$attribute doit être un multiple de 125 (soit 0.125)");
'required',
'numeric',
'gt:0',
function ($attribute, $value, $fail) {
if (fmod((\floatval($value) * 1000), 62.5) !== 0.0) {
$fail("$attribute doit être un multiple de 62.5 (soit 0.0625)");
}
}
],
'credit_account_id' => [
'required', 'exists:credit_accounts,id',
'required',
'exists:credit_accounts,id',
function ($attribute, $value, $fail) use ($ticket) {
/** @var \App\Models\Credit\Account|null */
$account = Account::whereId($value)->first();
@ -57,11 +61,11 @@ class CreateEstimateRequest extends FormRequest
*
* @return array
*/
public function messages(): array
public function attributes(): array
{
return [
'amount' => 'Montant',
'credit_account_id' => 'Compte'
'credit_account_id' => 'Compte à débiter'
];
}
}

View file

@ -26,7 +26,7 @@ class StoreCreditLogRequest extends FormRequest
{
return [
'amount' => [
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
'required', 'numeric', 'min:0', 'max:255', function ($attribute, $value, $fail) {
if (($value * 10) % 5 !== 0) {
$fail("Le Montant de l'opération doit être divisible par 0.5 jour/homme");

View file

@ -1,47 +0,0 @@
<?php
namespace App\Http\Requests\Bo\Dutyhours;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class StoreDutyhourRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return Gate::allows('isAdmin');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'date' => 'required|date|after_or_equal:today',
'person' => 'required|string|min:3|max:255',
'place' => 'required|string|min:3|max:255',
];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'date' => trans('Date de la permanence'),
'person' => trans('Personne associée à la permanence'),
'place' => trans('Lieu de la permanence'),
];
}
}

View file

@ -1,7 +0,0 @@
<?php
namespace App\Http\Requests\Bo\Dutyhours;
class UpdateDutyhourRequest extends StoreDutyhourRequest
{
}

View file

@ -1,37 +0,0 @@
<?php
namespace App\Http\Requests\Bo;
use App\Enums\Planning\TableRowEnum;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;
class EraseCellContentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return auth()->check() and $this->ajax();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'required|exists:week_plannings,id',
'day' => 'required|numeric',
'row' => [
'required',
new Enum(TableRowEnum::class)
],
];
}
}

View file

@ -28,7 +28,7 @@ class StoreInvoiceRequest extends FormRequest
protected function prepareForValidation()
{
$this->merge([
'tasks' => request()->tasks ? \collect(json_decode(request()->tasks))
'tasks' => request()->tasks ? \collect(json_decode(request()->tasks))
->map(function ($task) {
return \array_intersect_key((array)$task, Invoice::getTaskStructure());
})->toArray() : [],
@ -44,24 +44,24 @@ class StoreInvoiceRequest extends FormRequest
public function rules()
{
return [
'firstname' => 'required|string|min:3|max:255',
'lastname' => 'required|string|min:3|max:255',
'object' => 'required|string|min:3|max:255',
'tasks' => 'required|array|min:1',
'tasks.*' => 'required|array',
'tasks.*.days' => 'required|numeric|min:0.125',
'tasks.*.amount' => 'required|numeric|min:0.125',
'tasks.*.desc' => 'required|string|min:10',
'tasks.*.type' => [
'firstname' => 'required|string|min:3|max:255',
'lastname' => 'required|string|min:3|max:255',
'object' => 'required|string|min:3|max:255',
'tasks' => 'required|array|min:1',
'tasks.*' => 'required|array',
'tasks.*.days' => 'required|numeric',
'tasks.*.amount' => 'required|numeric',
'tasks.*.desc' => 'required|string|min:10',
'tasks.*.type' => [
'required', new Enum(TaskTypeEnum::class)
],
'tasks.*.package' => 'required_if:tasks.*.type,' . TaskTypeEnum::package->value .
'|nullable|exists:packages,id',
'comment' => 'sometimes|nullable|string|min:15',
'show_days' => 'required|boolean',
'site_id' => 'required|integer|exists:sites,id',
'company_id' => 'required|integer|exists:companies,id',
'invoiced_to_id' => 'required|integer|exists:companies,id',
'comment' => 'sometimes|nullable|string|min:15',
'show_days' => 'required|boolean',
'site_id' => 'required|integer|exists:sites,id',
'company_id' => 'required|integer|exists:companies,id',
'invoiced_to_id' => 'required|integer|exists:companies,id',
];
}

View file

@ -21,13 +21,14 @@ class UpdateInvoiceRequest extends StoreInvoiceRequest
$rules = array_merge($rules, parent::rules());
}
$rules = array_merge($rules, [
'sent_client_date' => 'required_with:signed_date,sent_accounting_date|sometimes|nullable|date',
'signed_date' => 'required_with:sent_accounting_date|sometimes|nullable|date',
'comment' => 'sometimes|nullable|string|min:15',
'sent_client_date' => 'required_with:signed_date,sent_accounting_date|sometimes|nullable|date',
'signed_date' => 'required_with:sent_accounting_date|sometimes|nullable|date',
'sent_accounting_date' => 'sometimes|nullable|date',
'status' => [
'status' => [
'required',
new Enum(InvoiceStatusEnum::class),
//phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
//phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
function ($attribute, $value, $fail) use ($model) {
if (
(intval($value) === InvoiceStatusEnum::archived->value) &&

View file

@ -2,9 +2,9 @@
namespace App\Http\Requests\Bo\Labels;
use App\Rules\Hex;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
use LVR\Colour\Hex;
class StoreLabelRequest extends FormRequest
{

View file

@ -0,0 +1,39 @@
<?php
namespace App\Http\Requests\Bo;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;
class LinkTicket extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
/** @var \App\Models\User|null $user */
$user = Auth::user();
return Auth::check() && $user->isAdmin();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
$ticket = $this->route('ticket');
return [
'linked_ticket_id' => [
'required',
'numeric',
'exists:tickets,id',
'not_in:' . $ticket->id,
]
];
}
}

View file

@ -17,6 +17,18 @@ class StorePackageRequest extends FormRequest
return Gate::allows('isAdmin');
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation(): void
{
$this->merge([
'published' => $this->boolean('published'),
]);
}
/**
* Get the validation rules that apply to the request.
*
@ -27,6 +39,7 @@ class StorePackageRequest extends FormRequest
return [
'name' => 'required|string|min:3|max:255',
'amount' => 'required|numeric|min:0|regex:/^\d+(\.\d{1,2})?$/',
'published' => 'required|boolean',
];
}
@ -40,6 +53,7 @@ class StorePackageRequest extends FormRequest
return [
'name' => trans('Nom'),
'amount' => trans('Montant (par jour)'),
'published' => trans('Publication')
];
}
}

View file

@ -1,32 +0,0 @@
<?php
namespace App\Http\Requests\Bo\Projects;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class StoreProjectRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return Gate::allows('isAdmin');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|string|min:3|max:255|unique:projects,name',
'site_id' => 'required|exists:sites,id',
];
}
}

View file

@ -1,18 +0,0 @@
<?php
namespace App\Http\Requests\Bo\Projects;
class UpdateProjectRequest extends StoreProjectRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return array_merge(parent::rules(), [
'name' => 'required|string|min:3|max:255|unique:projects,name,' . $this->route('project')->id . ',id',
]);
}
}

View file

@ -1,68 +0,0 @@
<?php
namespace App\Http\Requests\Bo;
use App\Enums\Planning\CellModelEnum;
use App\Enums\Planning\CellTypeEnum;
use App\Enums\Planning\TableRowEnum;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;
class SetCellContentRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
$this->merge([
'model' => $this->model ?? null,
'foreign' => $this->foreign ?? null,
'text' => $this->text ?? ''
]);
return auth()->check() and $this->ajax();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
'id' => 'required|exists:week_plannings,id',
'day' => 'required|numeric',
'row' => [
'required',
new Enum(TableRowEnum::class)
],
'type' => [
'required',
new Enum(CellTypeEnum::class)
],
'CellModelEnum' => \sprintf(
'nullable',
new Enum(CellModelEnum::class)
),
'foreign' => 'required_with:CellModelEnum|nullable|numeric',
'text' => 'required|string|min:5|max:90'
];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'CellModelEnum' => 'Type d\'élément lié',
'foreign' => 'Élément lié',
'text' => 'Description courte'
];
}
}

View file

@ -28,7 +28,8 @@ class StoreSiteRequest extends FormRequest
'name' => 'required|string|min:3|max:255',
'users' => 'nullable|array',
'users.*.id' => 'required|exists:users,id',
'gitlab_project_id' => 'nullable|unique:sites,gitlab_project_id',
'gitlab_project_id' => 'nullable',
'project_manager_id' => 'nullable|exists:users,id',
'url_re7' => 'nullable|url',
'url_prod' => 'nullable|url'
];
@ -46,6 +47,7 @@ class StoreSiteRequest extends FormRequest
'users' => trans('Utilisateurs associés au site'),
'users.*.id' => trans('Élément parmis les Utilisateurs associés au site'),
'gitlab_project_id' => trans('ID du dépôt Gitlab'),
'project_manager_id' => trans('Chef de projet'),
'url_re7' => trans('Url de RECETTE'),
'url_prod' => trans('Url de prod')
];

View file

@ -4,15 +4,4 @@ namespace App\Http\Requests\Bo\Sites;
class UpdateSiteRequest extends StoreSiteRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return array_merge(parent::rules(), [
'gitlab_project_id' => 'nullable|unique:sites,gitlab_project_id,' . $this->route('site')->id . ',id',
]);
}
}

View file

@ -29,7 +29,7 @@ class SortTickets extends FormRequest
'sort_way' => 'sometimes|in:asc,desc',
'status' => [
'sometimes',
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
function ($attribute, $value, $fail) {
if (!in_array($value, TicketStatusEnum::toValues())) {
$fail(__('Veuillez choisir entre :values', [

View file

@ -60,7 +60,7 @@ class StoreTicket extends FormRequest
'site_id' => [
'required',
'exists:sites,id',
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
function ($attribute, $value, $fail) {
/** @var \App\Models\User */
$user = auth()->user();
@ -76,7 +76,7 @@ class StoreTicket extends FormRequest
],
'type' => [
'required',
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
function ($attribute, $value, $fail) {
if (!in_array($value, TicketTypeEnum::toValues())) {
$fail(__('Veuillez choisir entre :values', [
@ -87,7 +87,7 @@ class StoreTicket extends FormRequest
],
'status' => [
'required',
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
function ($attribute, $value, $fail) {
if (!in_array($value, TicketStatusEnum::toValues())) {
$fail(__('Veuillez choisir entre :values', [
@ -96,13 +96,29 @@ class StoreTicket extends FormRequest
}
}
],
'text' => 'required|string|min:40',
'file_ticket' => 'mimes:jpeg,jpg,png,pdf|max:2048',
'file_ticket2' => 'mimes:jpeg,jpg,png,pdf|max:2048',
'is_internal' => 'required|boolean',
'labels' => 'sometimes|array',
'labels.*' => [
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
'date_mep' => 'nullable|date',
'text' => [
'required',
'string',
'min:40',
function ($attribute, $value, $fail) {
$forbidden = ['merci de', 'merci de'];
foreach ($forbidden as $word) {
if (stripos(strtolower($value), $word) !== false) {
$fail(
"Le champs 'Description du ticket' contient la chaine de caractère non autorisée suivante : $word"
);
}
}
},
],
'title' => 'required|string|between:3,255',
'file_tickets' => 'sometimes|array',
'file_tickets.*' => 'mimes:pptx,docx,xlsx,csv,txt,jpeg,jpg,png,pdf,svg|max:2048',
'is_internal' => 'required|boolean',
'labels' => 'sometimes|array',
'labels.*' => [
// @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
'required', 'exists:labels,id', function ($attribute, $value, $fail) use ($user) {
if (!$user->can('assignLabels', Ticket::class)) {
$fail(trans('Vous n\'êtes pas autorisé à modifier cette valeur'));

View file

@ -0,0 +1,42 @@
<?php
namespace App\Http\Requests\Bo;
use Illuminate\Foundation\Http\FormRequest;
class UpdateChangeOrderRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return auth()->check();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation(): void
{
$this->merge([
'direction' => $this->route('direction') === 'up' ? true : false
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
'direction' => 'required|boolean',
];
}
}

View file

@ -0,0 +1,57 @@
<?php
namespace App\Http\Requests\Bo;
use App\Models\Ticket;
use Illuminate\Foundation\Http\FormRequest;
class UpdateTicketPriorityRequest extends FormRequest
{
private \App\Models\Ticket $ticket;
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return auth()->check();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation(): void
{
$this->ticket = $this->route('ticket');
$max = Ticket::query()->where('site_id', $this->ticket->site_id)->max('order');
$this->merge([
'priority' => min($this->integer('priority'), $max)
]);
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
'priority' => [
'required',
'integer',
'min:1',
function ($attribute, $value, $fail) {
if ($this->ticket && intval($value) === $this->ticket->order) {
$fail("La valeur de {$attribute} doit être différente de la valeur actuelle.");
}
},
],
];
}
}

View file

@ -0,0 +1,39 @@
<?php
namespace App\Http\Requests\Bo\Users;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Auth;
use Illuminate\Foundation\Http\FormRequest;
class FavouriteSiteRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return Auth::check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
/** @var \App\Models\User|null $user */
$user = Auth::user();
return [
'favourite_site_id' => [
'nullable',
'exists:sites,id',
Rule::in($user->sites->pluck('id')),
],
];
}
}

View file

@ -19,6 +19,18 @@ class StoreUserRequest extends FormRequest
return Gate::allows('isAdmin');
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation(): void
{
$this->merge([
'gitlab_id' => \boolval($this->input('gitlab_id')) ? $this->input('gitlab_id') : null
]);
}
/**
* Get the validation rules that apply to the request.
*
@ -28,13 +40,18 @@ class StoreUserRequest extends FormRequest
{
return [
'name' => 'required|string|min:3|max:255',
'email' => 'email|required|unique:users,email',
'email' => [
'email',
'required',
Rule::unique('users', 'email')->whereNull('deleted_at')
],
'role' => [
'required',
Rule::in(collect(RoleEnum::cases())->pluck('value')->all()),
],
'sites' => 'nullable|array',
'sites.*.id' => 'required|exists:sites,id'
'sites.*.id' => 'required|exists:sites,id',
'gitlab_id' => 'nullable|integer|unique:users,gitlab_id'
];
}
@ -51,6 +68,7 @@ class StoreUserRequest extends FormRequest
'role' => trans('Rôle de l\'utilisateur'),
'sites' => trans('Sites associés à l\'utilisateur'),
'sites.*.id' => trans('Élément parmis les sites associés à l\'utilisateur'),
'gitlab_id' => trans("ID de l'utilisateur Gitlab")
];
}
}

View file

@ -12,7 +12,8 @@ class UpdateUserRequest extends StoreUserRequest
public function rules()
{
return array_merge(parent::rules(), [
'email' => 'email|required|unique:users,email,' . $this->route('user')->id . ',id',
'email' => 'email|required|unique:users,email,' . $this->route('user')->id . ',id',
'gitlab_id' => 'nullable|integer|unique:users,gitlab_id,' . $this->route('user')->id . ',id'
]);
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace App\Interfaces;
interface SpsConfigInterface
{
/**
* URL method
* Website (SP) url ex: https://le-gaulois-pro.s-web.test
*
* @return string
*/
public function url(): string;
/**
* acsBase64 method
* Return destination url base64 encoded
*
* @return string
*/
public function acsBase64(): string;
/**
* destination method
* Return acs url concatenated with url
*
* @return string
*/
public function destination(): string;
/**
* logout method
* Return sls url concatenated with url
*
* @return string
*/
public function logout(): string;
/**
* certificate method
* Return certificate (.pem) file from kebab case of Enum name
*
* @return string
*/
public function certificate(): string;
}

View file

@ -0,0 +1,117 @@
<?php
namespace App\Jobs;
use App\Enums\Tickets\TicketStatusEnum;
use App\Models\Site;
use App\Models\Ticket;
use App\Notifications\ExportTicketsStateNotification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Notification;
class ExportTicketsState implements ShouldQueue
{
use Queueable;
/**
* CSV File headers
*
* @var array
*/
private $header = [
"Priorité service",
"Site",
"Numéro de ticket",
"Priorité",
"Date de MEP souhaitée",
"Type de ticket",
"Titre du ticket",
"Statut du ticket",
"Chef de projet",
"Utilisateur assigné",
"Date de dernière activité",
"Date de création",
"Lien vers le ticket",
"Lien vers l'issue GitLab"
];
/**
* Execute the job.
*
* @return void
*/
public function handle(): void
{
// L'ordre commence à 0 et reprendra à 1 pour chaque site.
$order = 0;
// Dernier site traité.
$lastSiteId = null;
// Insertion de la ligne d'en-têtes.
$csvlines[] = $this->header;
// Récupération des tickets.
Ticket::query()
->whereNotIn(
'status',
[TicketStatusEnum::archived, TicketStatusEnum::production]
)
->orderBy(Site::select('name')
->whereColumn('sites.id', 'tickets.site_id'))
->orderBy('order')->get()->each(function (Ticket $ticket) use (&$csvlines, &$lastSiteId, &$order) {
$csvlines[] = [
"",
$ticket->site->name,
$ticket->id,
$lastSiteId === $ticket->site_id ? $order + 1 : 1,
$ticket->date_mep?->format('d-m-Y') ?? 'No MEP Date',
$ticket->type->label(),
$ticket->title,
$ticket->status->label(),
$ticket->projectManager->name ?? 'No PM',
$ticket->assignedUser()->name ?? 'No Assigned User',
Carbon::create($ticket->getRawOriginal('last_activity'))->format('d-m-Y H:i:s'),
$ticket->created_at->format('d-m-Y H:i:s'),
route('bo.ticket.show', $ticket->id),
$ticket->gitlab_issue ?? 'No GitLab Issue'
];
$order = $lastSiteId === $ticket->site_id ? $order + 1 : 1;
$lastSiteId = $ticket->site_id;
});
Notification::route('mail', config('mail.MAIL_ADMIN'))
->notify(new ExportTicketsStateNotification($this->array2csv($csvlines, ";")));
}
/**
* converts an array to a csv stream
*
* @param array $data
* @param string $delimiter
* @param string $enclosure
* @param string $escape_char
*
* @return string
*/
protected function array2csv(
array $data,
string $delimiter = ',',
string $enclosure = '"',
string $escape_char = "\\"
) {
$f = fopen('php://memory', 'r+');
// UTF-8 BOM.
$BOM = "\xEF\xBB\xBF";
fwrite($f, $BOM);
foreach ($data as $item) {
fputcsv($f, $item, $delimiter, $enclosure, $escape_char);
}
rewind($f);
return stream_get_contents($f);
}
}

View file

@ -0,0 +1,85 @@
<?php
namespace App\Jobs;
use App\Models\Ticket;
use App\Enums\Tickets\TicketStatusEnum;
use Illuminate\Foundation\Queue\Queueable;
use App\Traits\Controllers\HasGitlabIssue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Http\Requests\Bo\ChangeTicketStatus;
class UpdateIssueLabels implements ShouldQueue
{
use Queueable;
use HasGitlabIssue;
/** @var Ticket */
protected $ticket;
/** @var requestStatus */
protected $requestStatus;
/**
* Create a new job instance.
*
* @param \App\Models\Ticket $ticket
* @param string $request
*
* @return void
*/
public function __construct(Ticket $ticket, string $requestStatus)
{
$this->ticket = $ticket;
$this->requestStatus = $requestStatus;
}
/**
* Execute the job.
*/
public function handle(): void
{
$oldStatus = $this->ticket->status;
$requestStatus = (int) $this->requestStatus;
$gitlabIssue = $this->getGitlabIssue($this->ticket->site->gitlab_project_id, $this->ticket->gitlab_issue);
$issueLabels = $gitlabIssue['labels'];
if ($oldStatus === TicketStatusEnum::waiting && $requestStatus !== TicketStatusEnum::waiting->value) {
$issueLabels = array_values(array_diff($issueLabels, ['g-wait']));
}
switch ($requestStatus) {
case TicketStatusEnum::takenInAccount->value:
$newLabels = ['g-to-dispatch'];
$updatedLabels = array_unique(array_merge($issueLabels, $newLabels));
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
break;
case TicketStatusEnum::waiting->value:
$newLabels = ['g-wait'];
$updatedLabels = array_unique(array_merge($issueLabels, $newLabels));
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
break;
case TicketStatusEnum::waitingValidation->value:
$removeLabels = ['g-to-estimate'];
$updatedLabels = array_diff($issueLabels, $removeLabels);
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
break;
case TicketStatusEnum::recetteValidated->value:
$newLabels = ['g-re7-ok', 'to-prod'];
$updatedLabels = array_unique(array_merge($issueLabels, $newLabels));
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
break;
case TicketStatusEnum::archived->value:
$updatedIssue = $this->closeGitlabIssue($gitlabIssue['project_id'], $gitlabIssue['iid'], $issueLabels);
break;
default:
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $issueLabels);
break;
}
}
}

View file

@ -68,6 +68,18 @@ class ToolboxHelper
return \preg_match('/(\.png|\.jpg|\.jpeg|\.gif)$/', $url, $m) === 1;
}
/**
* Check uri points to pdf file
*
* @param string $url
* @return boolean
*/
public static function isPdfFile(string $url): bool
{
$m = [];
return \preg_match('/(\.pdf)$/', $url, $m) === 1;
}
/**
* Strip scheme (https) on oembed urls
* Only embed allowed are for MP4 self hosted videos right now
@ -339,7 +351,7 @@ class ToolboxHelper
): Builder {
$currentLocale = app()->currentLocale();
$locales = collect(config('app.locales'))
->mapWithKeys(fn (string $locale) => [$locale => $locale]);
->mapWithKeys(fn(string $locale) => [$locale => $locale]);
if (!$locales->has($defaultLocale)) {
// * Remove default locale.
$locales->pull($defaultLocale);
@ -357,7 +369,7 @@ class ToolboxHelper
$q->whereRaw("JSON_EXTRACT({$column}, '$.{$currentLocale}') = '{$value}'");
}
// * Query any other locale
$locales->each(fn ($locale) => $q->orWhereRaw(
$locales->each(fn($locale) => $q->orWhereRaw(
"JSON_EXTRACT({$column}, '$.{$locale}') = '{$value}'"
));
});
@ -449,7 +461,10 @@ class ToolboxHelper
$fileFullPath = self::getUploadedFileFullPath($value, $useStorage);
if (
!\in_array(self::getUploadedFileMimeType($value, $useStorage), [
'image/jpeg', 'image/jpg', 'image/png', 'image/gif'
'image/jpeg',
'image/jpg',
'image/png',
'image/gif'
])
) {
$fail(trans(':attribute doit être une image de type \'image/jpeg,image/jpg,image/png,image/gif\'', [

View file

@ -22,8 +22,7 @@ class AddStatusMessages
$message = new Message();
$message->ticket_id = $event->ticket->id;
// * Le message system est privé si demandé (eg: Assignation à une personne).
$message->type = $event->is_private ?
MessageTypeEnum::public : MessageTypeEnum::private;
$message->type = $event->is_private ? MessageTypeEnum::private : MessageTypeEnum::public;
if ($event->message) {
$message->message = $event->message;
} elseif ($event->user) {

View file

@ -0,0 +1,75 @@
<?php
namespace App\Listeners;
use App\Events\BrevoWebhookCallReceived;
use App\Events\TicketCreated;
use App\Mail\NewTicket;
use App\Repositories\SiteRepository;
use App\Services\AutomaticTicketCreator;
use Domain\Models\ValueObjects\Email;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Mail;
use Psr\Log\LoggerInterface;
// NOTE: this should be queued in order to be eventually retried or at least keep info data.
class CreateTicketAutomatically implements ShouldQueue
{
private const string SITE_NAME_WHERE_TO_CREATE_TICKET = 'Mailing en masse';
public function __construct(
private readonly LoggerInterface $logger,
private readonly AutomaticTicketCreator $automaticTicketCreator,
private readonly SiteRepository $siteRepository,
private readonly Dispatcher $dispatcher
) {}
public function handle(BrevoWebhookCallReceived $event): void
{
$fromEmail = $event->from;
$toEmail = $event->to;
$htmlRawContent = $event->htmlRawContent;
$this->logger->info('Received a ticket creation event from brevo');
$this->logger->debug(
'Payload for ticket creation form brevo',
[
'from_email' => $fromEmail->value,
'to_email' => $toEmail->value,
'html_raw_content' => base64_encode($htmlRawContent)
]
);
$siteReceivingTickets = $this->siteRepository->findByName(self::SITE_NAME_WHERE_TO_CREATE_TICKET);
if ($siteReceivingTickets === null) {
throw new \UnexpectedValueException(
'No site found with name \'' .
self::SITE_NAME_WHERE_TO_CREATE_TICKET . '\''
);
}
$projectManager = $siteReceivingTickets->projectManager()->first();
if ($projectManager === null) {
throw new \UnexpectedValueException(
'No project manager found for site \'' .
self::SITE_NAME_WHERE_TO_CREATE_TICKET . '\''
);
}
$ticket = $this->automaticTicketCreator->createTicket(
$siteReceivingTickets,
$projectManager,
$htmlRawContent,
);
$this->dispatcher->dispatch(new TicketCreated(
siteReceivingTicket: $siteReceivingTickets,
ticket: $ticket,
byUserName: $fromEmail->value
));
}
}

View file

@ -3,21 +3,51 @@
namespace App\Listeners;
use App\Events\NotifyAdmin;
use App\Events\TicketCreated;
use App\Mail\NewTicket;
use App\Mail\TicketUpdate;
use Domain\Models\ValueObjects\Email;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Mail;
class SendNotificationMailToAdmin
{
private readonly Email $mailAdmin;
public function __construct()
{
$this->mailAdmin = new Email(
Config::string('mail.MAIL_ADMIN')
);
}
/**
* Handle the event.
*
* @param \App\Events\NotifyAdmin $event
* @return void
*/
public function handle(NotifyAdmin $event)
public function handle(NotifyAdmin | TicketCreated $event)
{
$ticket = $event->ticket;
Mail::to(config('mail.MAIL_ADMIN'))
->send(new TicketUpdate($ticket, $event->corpsMaj));
if ($event instanceof NotifyAdmin) {
$ticket = $event->ticket;
Mail::to($this->mailAdmin->value)
->send(new TicketUpdate($ticket, $event->corpsMaj));
}
if ($event instanceof TicketCreated) {
$ticket = $event->ticket;
$siteReceivingTickets = $event->siteReceivingTicket;
$userName = $event->byUserName;
Mail::to($this->mailAdmin->value)
->send(new NewTicket(
ticketId: $ticket->id,
siteName: $siteReceivingTickets->name,
ticketTitle: $ticket->title,
ticketType: $ticket->type,
userName: $userName,
ticketDescription: $ticket->text,
));
}
}
}

View file

@ -2,29 +2,23 @@
namespace App\Mail;
use App\Models\Ticket;
use App\Enums\Tickets\TicketTypeEnum;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class NewTicket extends Mailable
class NewTicket extends Mailable implements ShouldQueue
{
use Queueable;
use SerializesModels;
/** @var \App\Models\Ticket */
private $ticket;
/**
* Create a new message instance.
*
* @param \App\Models\Ticket $ticket
* @return void
*/
public function __construct(Ticket $ticket)
{
$this->ticket = $ticket;
}
public function __construct(
private readonly int $ticketId,
private readonly string $siteName,
private readonly string $ticketTitle,
private readonly TicketTypeEnum $ticketType,
private readonly string $userName,
private readonly string $ticketDescription,
) {}
/**
* Build the message.
@ -33,8 +27,14 @@ class NewTicket extends Mailable
*/
public function build()
{
$ticket = $this->ticket;
return $this->subject("[Support] Nouveau ticket n°" . $ticket->id)
->view('emails.new-ticket', compact('ticket'));
return $this->subject("[Support] Nouveau ticket n° {$this->ticketId} - {$this->ticketTitle}")
->view('emails.new-ticket', [
'ticketId' => $this->ticketId,
'siteName' => $this->siteName,
'ticketTitle' => $this->ticketTitle,
'ticketType' => $this->ticketType,
'userName' => $this->userName,
'ticketDescription' => $this->ticketDescription,
]);
}
}

View file

@ -41,7 +41,7 @@ class TicketMention extends Mailable
{
$ticket = $this->ticket;
$corpsMaj = ToolboxHelper::plainToHtml($this->corpsMaj);
return $this->subject("[Support] Vous avez été mentionné sur le ticket n° $ticket->id")
->view('emails.ticket-mention', compact('ticket', 'corpsMaj'));
return $this->subject("[Support] Vous avez été mentionné sur le ticket n°$ticket->id - $ticket->title")
->view('emails.ticket-mention', compact('ticket', 'corpsMaj'));
}
}

View file

@ -41,7 +41,7 @@ class TicketUpdate extends Mailable
{
$ticket = $this->ticket;
$corpsMaj = \html_entity_decode(ToolboxHelper::plainToHtml($this->corpsMaj));
return $this->subject("[Support][{$ticket->site->name}] Ticket n°$ticket->id")
->view('emails.ticket-update', compact('ticket', 'corpsMaj'));
return $this->subject("[Support][{$ticket->site->name}] Ticket n°$ticket->id - $ticket->title")
->view('emails.ticket-update', compact('ticket', 'corpsMaj'));
}
}

View file

@ -7,7 +7,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property string $name
* @property int $id Doit correspondre aux ids marques de la CRM
* @property string $name Nom de la marque
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection<int, Account> $accounts
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Site> $sites
* @mixin \Eloquent
*/
class Brand extends Model
{

View file

@ -7,7 +7,14 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\Attribute;
/**
* @property int $id
* @property string $name
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
* @property-read mixed $value
* @method static \Database\Factories\CompanyFactory factory($count = null, $state = [])
* @mixin \Eloquent
*/
class Company extends Model
{

View file

@ -7,10 +7,16 @@ use App\Models\Brand;
use Illuminate\Database\Eloquent\Model;
/**
* @property string $label
* @property AccountTypeEnum $type
* @property integer $balance
* @property Brand $brand_id
* @property int $id
* @property AccountTypeEnum $type Enum Credit\AccountTypeEnum
* @property string $label Custom account label
* @property float $balance Account balance
* @property int $brand_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read Brand $brand
* @property-read \App\Models\Credit\CreditLog|null $creditlogs
* @mixin \Eloquent
*/
class Account extends Model
{

View file

@ -6,10 +6,15 @@ use App\Enums\Credit\BalanceOperationEnum;
use Illuminate\Database\Eloquent\Model;
/**
* @property BalanceOperationEnum $type
* @property double $amount
* @property Account $credit_account_id
* @property date $created_at
* @property int $id
* @property BalanceOperationEnum $type Enum Credit\BalanceOperationEnum
* @property float $amount Montant de l'opération
* @property int $credit_account_id
* @property string $created_at
* @property-read \App\Models\Credit\Account $account
* @property-read \App\Models\Credit\EstimationLog|null $pivot
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Credit\Estimation> $estimation
* @mixin \Eloquent
*/
class CreditLog extends Model
{

View file

@ -9,6 +9,22 @@ use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Validation\ValidationException;
/**
* @property int $id
* @property EstimationStatusEnum $status Enum Credit\EstimationStatusEnum
* @property numeric $amount Estimation amount
* @property int $ticket_id
* @property int $credit_account_id The account to debit.
* @property int $estimator_id The person who has done the estimate.
* @property int|null $validator_id The person who has validate the estimate.
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Credit\Account $account
* @property-read User|null $estimator
* @property-read Ticket|null $ticket
* @property-read User|null $validator
* @mixin \Eloquent
*/
class Estimation extends Model
{
/**

View file

@ -4,6 +4,14 @@ namespace App\Models\Credit;
use Illuminate\Database\Eloquent\Relations\Pivot;
/**
* @property int $id
* @property int $credit_log_id
* @property int $credit_estimation_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @mixin \Eloquent
*/
class EstimationLog extends Pivot
{
/**

View file

@ -1,43 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property date $date
* @property string $person
* @property string $place
*/
class Dutyhour extends Model
{
use HasFactory;
/**
* Indicates if the model should be timestamped.
*
* @var boolean
*/
public $timestamps = true;
/**
* The attributes that are fillable.
*
* @var array
*/
protected $fillable = [
'date',
'person',
'place'
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $casts = [
'date' => 'date'
];
}

View file

@ -0,0 +1,60 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $title Gitlab issue title
* @property string $url Gitlab URL
* @property int $estimate_time Gitlab issue estimate time in seconds
* @property int $spent_time Gitlab issue spent time in seconds
* @property int $is_closed Gitlab issue status
* @property int $gitlab_id Gitlab issue id
* @property int $gitlab_iid Gitlab issue iid in project
* @property int|null $milestone_iid Gitlab issue linked milestone iid in project
* @property int $gitlab_project_id Gitlab project id
* @property string $g_created_at Gitlab issue created at
* @property string $g_updated_at Gitlab issue updated at
* @property string|null $g_closed_at Gitlab issue closed at
* @property string|null $g_due_date Gitlab issue due date
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\GitlabLabels> $gitlabLabels
* @mixin \Eloquent
*/
class GitlabIssues extends Model
{
/**
* Fillable array model
*
* @var array
*/
protected $fillable = [
'title',
'url',
'estimate_time',
'spent_time',
'is_closed',
'gitlab_id',
'gitlab_iid',
'milestone_iid',
'gitlab_project_id',
'g_created_at',
'g_updated_at',
'g_closed_at',
'g_due_date'
];
/**
* Gitlab Labels relationship
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function gitlabLabels()
{
return $this->belongsToMany(GitlabLabels::class, 'gitlab_issues_labels', 'issue_id', 'label_id')
->withTimestamps();
}
}

View file

@ -0,0 +1,38 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $name Label name
* @property int $gitlab_id Label Gitlab id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\GitlabIssues> $issues
* @mixin \Eloquent
*/
class GitlabLabels extends Model
{
/**
* Fillable array model
*
* @var array
*/
protected $fillable = [
'name',
'gitlab_id'
];
/**
* Gitlab Issues relationship
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function issues()
{
return $this->belongsToMany(GitlabIssues::class, 'gitlab_issues_labels', 'label_id', 'issue_id')
->withTimestamps();
}
}

View file

@ -0,0 +1,42 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $title Milestone title
* @property string $url Gitlab URL
* @property int $is_closed Gitlab milestone status
* @property int $gitlab_id Gitlab milestone id
* @property int $gitlab_iid Gitlab milestone iid in project
* @property int $gitlab_project_id Gitlab project id
* @property string $g_created_at Gitlab milestone created at
* @property string $g_updated_at Gitlab milestone updated at
* @property string|null $g_start_date Gitlab milestone start date
* @property string|null $g_due_date Gitlab milestone due date
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @mixin \Eloquent
*/
class GitlabMilestones extends Model
{
/**
* Fillable array model
*
* @var array
*/
protected $fillable = [
'title',
'url',
'is_closed',
'gitlab_id',
'gitlab_iid',
'gitlab_project_id',
'g_created_at',
'g_updated_at',
'g_start_date',
'g_due_date'
];
}

View file

@ -0,0 +1,30 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $name Gitlab project name
* @property string $url Gitlab URL
* @property int $is_archived Gitlab archive status
* @property int $gitlab_id Gitlab unique ID
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @mixin \Eloquent
*/
class GitlabProjects extends Model
{
/**
* Fillable array model
*
* @var array
*/
protected $fillable = [
'name',
'url',
'is_archived',
'gitlab_id'
];
}

View file

@ -7,9 +7,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $title
* @property string $message
* @property InfoColorsEnum $type
* @property InfoColorsEnum $type Defined by the InfoColorsEnum enum.
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @mixin \Eloquent
*/
class Information extends Model
{

View file

@ -10,28 +10,42 @@ use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Mccarlosen\LaravelMpdf\LaravelMpdf;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* @property string $ref
* @property string $firstname
* @property string $lastname
* @property string $object
* @property string $tasks
* @property double $total
* @property double $total_days
* @property string $comment
* @property boolean $show_days
* @property date $signed_date
* @property date $sent_client_date
* @property date $sent_accounting_date
* @property Site $site_id
* @property Company $company_id
* @property Company $invoiced_to_id
* @property InvoiceStatusEnum $status
* @property int $id
* @property string $ref The invoice reference built as YYYY_MM_INCREMENT_USER. INCREMENT is the N invoice of the month. USER is the first two letters of the user who last edited the invoice. This field has to generated only on create.
* @property string $firstname The person to which the invoice is addressed.
* @property string $lastname The person to which the invoice is addressed.
* @property string $object The invoice object.
* @property array<array-key, mixed> $tasks A JSON object, each line has to be contructed using these fields description, days, type Invoices\TaskTypeEnum, amount
* @property float $total The total calculated using all tasks
* @property float $total_days The total days calculated using all tasks
* @property string|null $comment Any comment joined to the invoice
* @property int $show_days Show days on the printed invoice
* @property Carbon|null $signed_date The date the invoice was signed
* @property Carbon|null $sent_client_date The date the invoice was send to the client
* @property Carbon|null $sent_accounting_date The date the invoice was send to the client
* @property int $site_id
* @property int $company_id
* @property int $invoiced_to_id
* @property InvoiceStatusEnum $status Status of the invoice.
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property-read \App\Models\Company $company
* @property-read \App\Models\Company $companyInvoiced
* @property-read \App\Models\Site|null $site
* @method static \Database\Factories\InvoiceFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder<static>|Invoice onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Invoice withTrashed(bool $withTrashed = true)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Invoice withoutTrashed()
* @mixin \Eloquent
*/
class Invoice extends Model
{
use HasFactory;
use SoftDeletes;
/**
* The attributes that are fillable.
@ -83,7 +97,7 @@ class Invoice extends Model
Carbon::now()->isoFormat('YYYY-MM'),
Str::padLeft((Invoice::whereYear('created_at', Carbon::now()->isoFormat('YYYY'))
->whereMonth('created_at', Carbon::now()->isoFormat('MM'))
->count() + 1) ?: 1, 4, '0'),
->count() + 1) ?: 1, 4, '0'),
Str::substr(Str::upper(Str::slug(Auth::user()->name)), 0, 1)
);
$model->total_days = collect($model->tasks)
@ -109,6 +123,10 @@ class Invoice extends Model
->reduce(function ($previous, array $task) {
return \floatval($task['amount']) + \floatval($previous);
});
if($model->sent_accounting_date && $model->status !== InvoiceStatusEnum::archived->value) {
$model->status = InvoiceStatusEnum::archived;
}
});
static::deleting(function () {
throw new \Error('Action impossible');
@ -192,30 +210,30 @@ class Invoice extends Model
'packages' => $packages,
],
[
'mode' => '',
'format' => 'A4',
'default_font_size' => '12',
'default_font' => 'sans-serif',
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0,
'orientation' => 'P',
'title' => __('Devis Équipe Web :ref', ['ref' => $this->ref]),
'author' => 'Equipe Web',
'watermark' => '',
'show_watermark' => false,
'watermark_font' => 'sans-serif',
'display_mode' => 'fullpage',
'watermark_text_alpha' => 0.1,
'custom_font_dir' => '',
'mode' => '',
'format' => 'A4',
'default_font_size' => '12',
'default_font' => 'sans-serif',
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'margin_header' => 0,
'margin_footer' => 0,
'orientation' => 'P',
'title' => __('Devis Équipe Web :ref', ['ref' => $this->ref]),
'author' => 'Equipe Web',
'watermark' => '',
'show_watermark' => false,
'watermark_font' => 'sans-serif',
'display_mode' => 'fullpage',
'watermark_text_alpha' => 0.1,
'custom_font_dir' => '',
'custom_font_data' => [],
'auto_language_detection' => false,
'temp_dir' => ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(),
'pdfa' => false,
'pdfaauto' => false,
'auto_language_detection' => false,
'temp_dir' => ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir(),
'pdfa' => false,
'pdfaauto' => false,
]
);
return $pdf;

View file

@ -7,6 +7,14 @@ use App\Lib\Helpers\ToolboxHelper;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $name Un ou deux mot désignant le label
* @property string $color Cast HTML color
* @property-read \App\Models\Site|null $site
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Ticket> $tickets
* @mixin \Eloquent
*/
class Label extends Model
{
use HasFactory;

View file

@ -9,12 +9,20 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
*
* @property string $message The message content.
* @property \App\Enums\MessageTypeEnum $type The message is not visible for clients.
* @property string $file The message joined file path.
*
* @package App\Models
* @property int $id
* @property int $ticket_id
* @property int|null $user_id
* @property string $message
* @property MessageTypeEnum $type Message Type defined by an enum.
* @property string|null $file
* @property string|null $file2 Pièce jointes n°2
* @property string|null $file3 Pièce jointes n°3
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Models\Ticket|null $ticket
* @property-read \App\Models\User|null $user
* @mixin \Eloquent
*/
class Message extends Model
{
@ -96,14 +104,9 @@ class Message extends Model
}
// ? Is message author is admin ?
if ($messageUser->isAdmin()) {
// Url: https://supportweb.ldc.fr/ticket/583/message/create.
// SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '583-8' for key 'PRIMARY'
// $ticket->subscriptions()->attach($messageUser);
// Add subscription.
if (!$messageUser->subscriptions()->find($ticket->id)) {
$messageUser->subscriptions()->attach($ticket->id);
\session()->flash('info', trans('Vous avez été inscrit.'));
}
$messageUser->subscriptions()->syncWithoutDetaching([$ticket->id]);
\session()->flash('info', trans('Vous avez été inscrit.'));
}
// * Send mail to other subscribed users
event(new NotifySubscriptions(

View file

@ -6,8 +6,12 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property int $id
* @property string $name
* @property double $amount
* @property float $amount The cost per day
* @property bool $published
* @method static \Database\Factories\PackageFactory factory($count = null, $state = [])
* @mixin \Eloquent
*/
class Package extends Model
{
@ -28,5 +32,16 @@ class Package extends Model
protected $fillable = [
'name',
'amount',
'published'
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'published' => 'boolean',
];
}

View file

@ -1,37 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property string $name
* @property Site $site_id
*/
class Project extends Model
{
use HasFactory;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'site_id'
];
// * RELATIONSHIPS.
/**
* BelongsTo Site
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function site()
{
return $this->belongsTo(Site::class);
}
}

View file

@ -6,14 +6,30 @@ use App\Lib\Helpers\ToolboxHelper;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* @property string $name
* @property string $url_re7
* @property string $url_prod
* @property integer $gitlab_project_id
* @property Brand $brand_id
* @property int $id
* @property string $name
* @property string|null $url_re7
* @property string|null $url_prod
* @property int|null $gitlab_project_id
* @property int|null $brand_id Relation is nullable, since not all site would be affiliate with a brand.
* @property int|null $project_manager_id Project manager relationship
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \App\Models\Brand|null $brand
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
* @property-read \App\Models\User|null $projectManager
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Ticket> $tickets
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $users
* @property-read mixed $value
* @method static \Illuminate\Database\Eloquent\Builder<static>|Site onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Site withTrashed(bool $withTrashed = true)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Site withoutTrashed()
* @mixin \Eloquent
*/
class Site extends Model
{
@ -29,7 +45,8 @@ class Site extends Model
'name',
'url_re7',
'url_prod',
'gitlab_project_id'
'gitlab_project_id',
'project_manager_id'
];
/**
@ -55,6 +72,10 @@ class Site extends Model
static::updating(function (self $model) {
self::manageFields($model);
});
static::deleted(function ($site) {
$site->invoices()->delete();
$site->tickets()->delete();
});
}
// * METHODS
@ -82,7 +103,7 @@ class Site extends Model
* HasMany Message relation
* The users of type client that would have access to this site tickets
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
* @return \Illuminate\Database\Eloquent\Relations\belongsToMany
*/
public function users()
{
@ -99,6 +120,16 @@ class Site extends Model
return $this->hasMany(Ticket::class, 'site_id');
}
/**
* HasMany Invoices relation
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function invoices()
{
return $this->hasMany(Invoice::class, 'site_id');
}
/**
* BelongsTo Brand relation
*
@ -110,13 +141,14 @@ class Site extends Model
}
/**
* BelongsTo Project relation
* BelongsTo User relation
* The project manager of the site
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function project()
public function projectManager(): BelongsTo
{
return $this->belongsTo(Project::class);
return $this->belongsTo(User::class, 'project_manager_id');
}
/**

View file

@ -4,6 +4,11 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Relations\Pivot;
/**
* @property int $site_id
* @property int $user_id
* @mixin \Eloquent
*/
class SiteUser extends Pivot
{
/**

View file

@ -2,26 +2,68 @@
namespace App\Models;
use App\Enums\Users\RoleEnum;
use App\Enums\Tickets\TicketStatusEnum;
use App\Enums\Tickets\TicketTypeEnum;
use App\Events\NotifyAdmin;
use App\Events\NotifySubscriptions;
use App\Events\TicketStatusChanged;
use App\Jobs\SendTicketMentionMail;
use App\Mail\TicketMention;
use Illuminate\Support\Str;
use App\Models\GitlabIssues;
use App\Enums\Users\RoleEnum;
use App\Models\Credit\Account;
use App\Models\Credit\Estimation;
use App\Models\Ticket\TicketType;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use App\Events\NotifySubscriptions;
use App\Events\TicketStatusChanged;
use App\Jobs\SendTicketMentionMail;
use App\Enums\Tickets\TicketTypeEnum;
use App\Enums\Tickets\TicketStatusEnum;
use Illuminate\Database\Eloquent\Model;
use GrahamCampbell\GitLab\Facades\GitLab;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\ModelNotFoundException;
/**
* @property int $id
* @property int $created_by
* @property int|null $assigned_to La personne a qui est assigné le ticket.
* @property int $site_id
* @property TicketTypeEnum $type
* @property string $title Titre du ticket
* @property string $text
* @property string|null $file
* @property string|null $file2
* @property string|null $file3 Pièce jointes n°3
* @property string|null $file4 Pièce jointes n°4
* @property string|null $file5 Pièce jointes n°5
* @property TicketStatusEnum $status
* @property int $order Ticket order.
* @property bool $is_internal
* @property string|null $gitlab_issue URL de l'issue Gitlab
* @property \Illuminate\Support\Carbon|null $date_mep Date MEP souhaitée
* @property int $last_activity Last activity on the ticket.
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read \App\Models\User|null $assignedUser
* @property-read Estimation|null $estimation
* @property-read string $full_name
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Label> $labels
* @property-read \Illuminate\Database\Eloquent\Collection<int, Ticket> $linkedTickets
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Message> $messages
* @property-read \App\Models\User|null $projectManager
* @property-read \App\Models\Site|null $site
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\User> $subscriptions
* @property-read TicketType|null $ticketType
* @property-read \App\Models\User|null $user
* @method static \Illuminate\Database\Eloquent\Builder<static>|Ticket onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Ticket withTrashed(bool $withTrashed = true)
* @method static \Illuminate\Database\Eloquent\Builder<static>|Ticket withoutTrashed()
* @mixin \Eloquent
*/
class Ticket extends Model
{
use HasFactory;
use SoftDeletes;
/**
* The attributes that are fillable.
@ -32,7 +74,10 @@ class Ticket extends Model
'site_id',
'type',
'status',
'order',
'date_mep',
'text',
'title',
'is_internal',
'last_activity',
];
@ -43,9 +88,10 @@ class Ticket extends Model
* @var array
*/
protected $casts = [
'is_internal' => 'bool',
'type' => TicketTypeEnum::class,
'status' => TicketStatusEnum::class,
'is_internal' => 'bool',
'type' => TicketTypeEnum::class,
'status' => TicketStatusEnum::class,
'date_mep' => 'date',
'last_activity' => 'timestamp',
];
@ -57,6 +103,7 @@ class Ticket extends Model
protected static function booted()
{
static::creating(function (Ticket $ticket) {
self::setOrder($ticket);
// If bug force the ticket status on new. All the others are estimateTodo.
if ($ticket->type->equals(TicketTypeEnum::bug)) {
$ticket->status = TicketStatusEnum::new;
@ -65,28 +112,54 @@ class Ticket extends Model
}
});
static::updating(function (Ticket $ticket) {
if (!$ticket->original['status'] !== $ticket->status->value) {
if (
!$ticket->original['status'] !== $ticket->status->value && $ticket->original['order'] === $ticket->order
) {
$user = auth()->user();
event(new TicketStatusChanged(
$ticket,
TicketStatusEnum::make($ticket->original['status']),
auth()->user(),
$user,
null,
false
));
event(new NotifySubscriptions($ticket, sprintf(
'<b>%s</b> a modifié le statut en <b>%s</b>',
auth()->user()->name,
$ticket->status->label()
)));
event(new NotifyAdmin($ticket, sprintf(
'<b>%s</b> a modifié le statut en <b>%s</b>',
auth()->user()->name,
$ticket->status->label()
)));
$message = $user ? sprintf('<b>%s</b> a modifié le statut en <b>%s</b>', $user->name, $ticket->status->label()) : sprintf('Le statut a été modifié en <b>%s</b>', $ticket->status->label());
event(new NotifySubscriptions($ticket, $message));
event(new NotifyAdmin($ticket, $message));
}
if ($ticket->status->equals(TicketStatusEnum::archived)) {
self::setOrder($ticket, true);
}
});
}
/**
* Set order after the last element of the list.
*
* @param self $model
* @param boolean $isArchived
* @return void
*/
private static function setOrder(self $model, bool $isArchived = false): void
{
$maxOrder = \intval(self::query()->where('status', '!=', TicketStatusEnum::archived)->max('order'));
if ($isArchived) {
$request = Ticket::query()
->where('site_id', $model->site_id)
->whereNot('status', TicketStatusEnum::archived)
->whereNot('id', $model->id)
->whereBetween('order', [$model->order, $maxOrder]);
$request->decrement('order', 1);
$model->order = 0;
return;
}
$model->order = $maxOrder + 1;
}
// * RELATIONSHIPS
/**
@ -131,6 +204,17 @@ class Ticket extends Model
return $this->belongsTo(User::class, 'assigned_to');
}
/**
* BelongsTo User relation
* The user that is in charge of the site linked to this ticket
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function projectManager()
{
return $this->belongsTo(User::class, 'project_manager_id');
}
/**
* HasMany Message relation
*
@ -172,6 +256,16 @@ class Ticket extends Model
return $this->belongsTo(TicketType::class, 'type', 'type');
}
/**
* BelongsToMany Linked Ticket
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function linkedTickets()
{
return $this->belongsToMany(Ticket::class, 'linked_tickets', 'ticket_id', 'linked_ticket_id');
}
// * METHODS
/**
@ -274,4 +368,20 @@ class Ticket extends Model
Str::limit(\preg_replace('/[[:cntrl:]]+/', '', $ticket->text), 35),
);
}
/**
* Get an array of all files columns of the ticket.
*
* @return array
*/
public function getFiles(): array
{
return [
$this->file,
$this->file2,
$this->file3,
$this->file4,
$this->file5,
];
}
}

View file

@ -9,8 +9,13 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* @property TicketTypeEnum $type
* @property string $template
* @property int $id
* @property TicketTypeEnum $type TicketType Enum
* @property string $template Le template du type de ticket
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection<int, Ticket> $tickets
* @mixin \Eloquent
*/
class TicketType extends Model
{

View file

@ -15,12 +15,27 @@ use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
/**
* @property int $id
* @property string $name
* @property string $email
* @property string $password
* @property string $remember_token
* @property RoleEnum $role
* @property Collection $sites
* @property string|null $remember_token
* @property int|null $gitlab_id ID du user Gitlab
* @property int|null $favourite_site_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property \Illuminate\Support\Carbon|null $deleted_at
* @property-read Collection<int, \App\Models\Message> $messages
* @property-read \Illuminate\Notifications\DatabaseNotificationCollection<int, \Illuminate\Notifications\DatabaseNotification> $notifications
* @property-read Collection<int, \App\Models\Site> $sites
* @property-read Collection<int, \App\Models\Ticket> $subscriptions
* @property-read Collection<int, \App\Models\Ticket> $tickets
* @method static \Database\Factories\UserFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder<static>|User onlyTrashed()
* @method static \Illuminate\Database\Eloquent\Builder<static>|User withTrashed(bool $withTrashed = true)
* @method static \Illuminate\Database\Eloquent\Builder<static>|User withoutTrashed()
* @mixin \Eloquent
*/
class User extends Authenticatable
{
@ -45,7 +60,9 @@ class User extends Authenticatable
'email',
'password',
'role',
'sites'
'sites',
'gitlab_id',
'favourite_site_id'
];
/**
@ -148,8 +165,8 @@ class User extends Authenticatable
*/
public static function adminUsers(): Collection
{
return Cache::rememberForever('AdminUsers', function () {
return self::whereIn('role', [RoleEnum::admin, RoleEnum::developper])->get();
return Cache::remember('AdminUsers', 86400, function () {
return self::whereIn('role', [RoleEnum::admin, RoleEnum::developper])->orderBy('name')->get();
});
}

View file

@ -0,0 +1,60 @@
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Carbon;
class ExportTicketsStateNotification extends Notification implements ShouldQueue
{
use Queueable;
/**
* The CSV content to be sent.
*
* @var string
*/
private string $csvContent;
/**
* Create a new notification instance.
*
* @param string $csvContent The content of the CSV file to be sent.
*/
public function __construct(string $csvContent)
{
$this->csvContent = $csvContent;
}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(): array
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail(): \Illuminate\Notifications\Messages\MailMessage
{
return (new MailMessage())
->subject(trans("Export de l'état des lieux des tickets"))
->line(trans("Vous trouverez ci-joint le fichier CSV contenant l'état des tickets."))
->attachData(
$this->csvContent,
sprintf('tickets_state_%s.csv', Carbon::now()->format('Y-m-d_H-i-s')),
[
'mime' => 'text/csv',
]
);
}
}

View file

@ -67,6 +67,17 @@ class TicketPolicy
return $user->isAdmin();
}
/**
* Determine if the user can link ticket .
*
* @param \App\Models\User $user
* @return boolean
*/
public function linkTicket(User $user)
{
return $user->isAdmin();
}
/**
* Determine if the user can change the internal status of a given ticket.
*
@ -272,8 +283,25 @@ class TicketPolicy
public function createGitlabIssue(User $user, Ticket $ticket)
{
return $user->role->equals(RoleEnum::developper)
&& ($ticket->type->equals(TicketTypeEnum::bug) || $ticket->type->equals(TicketTypeEnum::evolution))
&& (
$ticket->type->equals(TicketTypeEnum::bug)
|| $ticket->type->equals(TicketTypeEnum::evolution)
|| $ticket->type->equals(TicketTypeEnum::newsletter)
|| $ticket->type->equals(TicketTypeEnum::mailing)
)
&& !\is_null($ticket->site->gitlab_project_id)
&& \is_null($ticket->gitlab_issue);
}
/**
* Determine if the user can changeOrder
*
* @param User $user
* @return boolean
* @throws Error The error.
*/
public function changeOrder(User $user)
{
return $user->role->equals(RoleEnum::developper);
}
}

View file

@ -2,12 +2,24 @@
namespace App\Providers;
use App\Repositories\EloquentSiteRepository;
use App\Repositories\SiteRepository;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Override;
class AppServiceProvider extends ServiceProvider
{
#[Override]
public function register()
{
$this->app->singleton(
SiteRepository::class,
fn() => new EloquentSiteRepository()
);
}
/**
* Bootstrap any application services.
*
@ -24,7 +36,7 @@ class AppServiceProvider extends ServiceProvider
return request()->getClientIp();
} else {
return request()->server('HTTP_X_FORWARDED_FOR') ??
request()->getClientIp();
request()->getClientIp();
}
});

View file

@ -2,14 +2,6 @@
namespace App\Providers;
use App\Events\NotifyAdmin;
use App\Events\NotifySubscriptions;
use App\Events\NotifyTicketCreator;
use App\Events\TicketStatusChanged;
use App\Listeners\AddStatusMessages;
use App\Listeners\SendNotificationMailToAdmin;
use App\Listeners\SendNotificationMailToTicketCreator;
use App\Listeners\SendSubscriptionsNotificationsMail;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
@ -23,10 +15,6 @@ class EventServiceProvider extends ServiceProvider
*/
protected $listen = [
Registered::class => [SendEmailVerificationNotification::class],
TicketStatusChanged::class => [AddStatusMessages::class],
NotifySubscriptions::class => [SendSubscriptionsNotificationsMail::class],
NotifyTicketCreator::class => [SendNotificationMailToTicketCreator::class],
NotifyAdmin::class => [SendNotificationMailToAdmin::class],
];
/**
@ -36,6 +24,6 @@ class EventServiceProvider extends ServiceProvider
*/
public function shouldDiscoverEvents(): bool
{
return false;
return true;
}
}

View file

@ -6,12 +6,10 @@ use App\Models\Brand;
use App\Models\Company;
use App\Models\Credit\Account;
use App\Models\Credit\CreditLog;
use App\Models\Dutyhour;
use App\Models\Information;
use App\Models\Invoice;
use App\Models\Label;
use App\Models\Package;
use App\Models\Project;
use App\Models\Site;
use App\Models\Ticket;
use App\Models\Ticket\TicketType;
@ -89,15 +87,12 @@ class RouteServiceProvider extends ServiceProvider
});
Route::model('brand', Brand::class);
Route::model('label', Label::class);
Route::model('marker', Marker::class);
Route::model('package', Package::class);
Route::model('dutyhour', Dutyhour::class);
Route::model('information', Information::class);
Route::model('company', Company::class);
Route::model('invoice', Invoice::class);
Route::model('user', User::class);
Route::model('site', Site::class);
Route::model('project', Project::class);
Route::model('ticket_type', TicketType::class);
Route::bind('ticket', function ($value) {
return Ticket::where('id', $value)->has('site')->firstOrFail();

View file

@ -19,7 +19,7 @@ class TranslationServiceProvider extends ServiceProvider
{
foreach ($this->collectLocalesStrings() as $locale) {
// * Supported locales
Cache::rememberForever(sprintf('translations.%s', $locale), function () use ($locale) {
Cache::remember(sprintf('translations.%s', $locale), 84600, function () use ($locale) {
$translations = [
'php' => $this->phpTranslations($locale),
'json' => $this->jsonTranslations($locale),

View file

@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace App\Repositories;
use App\Models\Site;
use Override;
class EloquentSiteRepository implements SiteRepository
{
#[Override]
public function findByName(string $name): ?Site
{
return Site::query()
->where('name', $name)
->first();
}
}

View file

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace App\Repositories;
use App\Models\Site;
interface SiteRepository
{
public function findByName(string $name): ?Site;
}

76
app/Rules/Hex.php Normal file
View file

@ -0,0 +1,76 @@
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\ValidationRule;
class Hex implements ValidationRule
{
/**
* @var boolean
*/
protected $forceFull;
/**
* @var boolean
*/
protected $allowAlpha;
/**
* __construct method
*
* @param boolean $forceFull
* @param boolean $allowAlpha
*
* @return void
*/
public function __construct(bool $forceFull = false, bool $allowAlpha = false)
{
$this->forceFull = $forceFull;
$this->allowAlpha = $allowAlpha;
}
/**
* Run the validation rule.
*
* @param string $attribute
* @param mixed $value
* @param \Closure(string):\Illuminate\Translation\PotentiallyTranslatedString $fail
* @return void
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
* @phpcs:disable Squiz.Commenting.FunctionComment.IncorrectTypeHint
*/
public function validate(string $attribute, mixed $value, \Closure $fail): void
{
$pattern = '/^#([a-fA-F0-9]{6}';
if (!$this->forceFull) {
$pattern .= '|[a-fA-F0-9]{3}';
}
if ($this->allowAlpha) {
$pattern .= '|[a-fA-F0-9]{8}';
if (!$this->forceFull) {
$pattern .= '|[a-fA-F0-9]{4}';
}
}
$pattern .= ')$/';
if (!(bool)preg_match($pattern, $value)) {
$fail(trans($this->message()));
}
}
/**
* Get the validation error message.
*
* @return string
*/
public function message(): string
{
return 'The hex code is not valid';
}
}

Some files were not shown because too many files have changed in this diff Show more