Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Clubphp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Clubphp
Commits
00f555fb
Commit
00f555fb
authored
May 18, 2026
by
Mahmoud Aglan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
a4373d67
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1338 additions
and
192 deletions
+1338
-192
PoolGridApiController.php
.../SportsActivity/Controllers/Api/PoolGridApiController.php
+32
-11
PoolGridTemplateApiController.php
...ctivity/Controllers/Api/PoolGridTemplateApiController.php
+123
-0
Routes.php
app/Modules/SportsActivity/Routes.php
+8
-0
PoolGridService.php
app/Modules/SportsActivity/Services/PoolGridService.php
+132
-92
PoolGridTemplateService.php
...dules/SportsActivity/Services/PoolGridTemplateService.php
+331
-0
manage.php
app/Modules/SportsActivity/Views/pool-grid/manage.php
+634
-89
Phase_70_023_create_sa_pool_zone_templates_table.php
...ions/Phase_70_023_create_sa_pool_zone_templates_table.php
+19
-0
Phase_70_024_create_sa_pool_zone_template_entries_table.php
...ase_70_024_create_sa_pool_zone_template_entries_table.php
+27
-0
Phase_70_025_create_sa_pool_zone_template_runs_table.php
.../Phase_70_025_create_sa_pool_zone_template_runs_table.php
+21
-0
Phase_70_026_add_template_run_id_to_pool_zone_bookings.php
...hase_70_026_add_template_run_id_to_pool_zone_bookings.php
+11
-0
No files found.
app/Modules/SportsActivity/Controllers/Api/PoolGridApiController.php
View file @
00f555fb
...
...
@@ -36,18 +36,25 @@ class PoolGridApiController extends Controller
{
$body
=
$request
->
jsonBody
();
$date
=
trim
((
string
)
(
$body
[
'date'
]
??
''
));
$startTime
=
trim
((
string
)
(
$body
[
'start_time'
]
??
''
));
$endTime
=
trim
((
string
)
(
$body
[
'end_time'
]
??
''
));
$action
=
trim
((
string
)
(
$body
[
'action'
]
??
''
));
$cells
=
$body
[
'cells'
]
??
[];
$groupId
=
!
empty
(
$body
[
'group_id'
])
?
(
int
)
$body
[
'group_id'
]
:
null
;
$notes
=
trim
((
string
)
(
$body
[
'notes'
]
??
''
));
if
(
!
$date
||
!
$startTime
||
!
$endTime
||
!
$action
||
empty
(
$cells
))
{
// Support multi-slot (slots array) or legacy single start_time/end_time
if
(
!
empty
(
$body
[
'slots'
])
&&
is_array
(
$body
[
'slots'
]))
{
$slots
=
$body
[
'slots'
];
}
else
{
$startTime
=
trim
((
string
)
(
$body
[
'start_time'
]
??
''
));
$endTime
=
trim
((
string
)
(
$body
[
'end_time'
]
??
''
));
$slots
=
[[
'start_time'
=>
$startTime
,
'end_time'
=>
$endTime
]];
}
if
(
!
$date
||
!
$action
||
empty
(
$cells
)
||
empty
(
$slots
))
{
return
$this
->
json
([
'error'
=>
'بيانات ناقصة'
],
400
);
}
$result
=
PoolGridService
::
bulkAssign
((
int
)
$id
,
$date
,
$s
tartTime
,
$endTime
,
$action
,
$cells
,
$groupId
,
$notes
?:
null
);
$result
=
PoolGridService
::
bulkAssign
((
int
)
$id
,
$date
,
$s
lots
,
$action
,
$cells
,
$groupId
,
$notes
?:
null
);
return
$this
->
json
(
$result
,
$result
[
'success'
]
?
200
:
422
);
}
...
...
@@ -56,14 +63,21 @@ class PoolGridApiController extends Controller
{
$body
=
$request
->
jsonBody
();
$date
=
trim
((
string
)
(
$body
[
'date'
]
??
''
));
$startTime
=
trim
((
string
)
(
$body
[
'start_time'
]
??
''
));
$cells
=
$body
[
'cells'
]
??
[];
if
(
!
$date
||
!
$startTime
||
empty
(
$cells
))
{
// Support multi-slot or legacy single start_time
if
(
!
empty
(
$body
[
'slots'
])
&&
is_array
(
$body
[
'slots'
]))
{
$slots
=
$body
[
'slots'
];
}
else
{
$startTime
=
trim
((
string
)
(
$body
[
'start_time'
]
??
''
));
$slots
=
[[
'start_time'
=>
$startTime
]];
}
if
(
!
$date
||
empty
(
$cells
)
||
empty
(
$slots
))
{
return
$this
->
json
([
'error'
=>
'بيانات ناقصة'
],
400
);
}
$result
=
PoolGridService
::
bulkClear
((
int
)
$id
,
$date
,
$s
tartTime
,
$cells
);
$result
=
PoolGridService
::
bulkClear
((
int
)
$id
,
$date
,
$s
lots
,
$cells
);
return
$this
->
json
(
$result
);
}
...
...
@@ -88,14 +102,21 @@ class PoolGridApiController extends Controller
$body
=
$request
->
jsonBody
();
$date
=
trim
((
string
)
(
$body
[
'date'
]
??
''
));
$fromTime
=
trim
((
string
)
(
$body
[
'from_time'
]
??
''
));
$toTime
=
trim
((
string
)
(
$body
[
'to_time'
]
??
''
));
$toEndTime
=
trim
((
string
)
(
$body
[
'to_end_time'
]
??
''
));
if
(
!
$date
||
!
$fromTime
||
!
$toTime
||
!
$toEndTime
)
{
// Support multi-target (to_slots array) or legacy single to_time/to_end_time
if
(
!
empty
(
$body
[
'to_slots'
])
&&
is_array
(
$body
[
'to_slots'
]))
{
$toSlots
=
$body
[
'to_slots'
];
}
else
{
$toTime
=
trim
((
string
)
(
$body
[
'to_time'
]
??
''
));
$toEndTime
=
trim
((
string
)
(
$body
[
'to_end_time'
]
??
''
));
$toSlots
=
[[
'start'
=>
$toTime
,
'end'
=>
$toEndTime
]];
}
if
(
!
$date
||
!
$fromTime
||
empty
(
$toSlots
))
{
return
$this
->
json
([
'error'
=>
'بيانات ناقصة'
],
400
);
}
$result
=
PoolGridService
::
copySlot
((
int
)
$id
,
$date
,
$fromTime
,
$to
Time
,
$toEndTime
);
$result
=
PoolGridService
::
copySlot
((
int
)
$id
,
$date
,
$fromTime
,
$to
Slots
);
return
$this
->
json
(
$result
,
$result
[
'success'
]
?
200
:
422
);
}
...
...
app/Modules/SportsActivity/Controllers/Api/PoolGridTemplateApiController.php
0 → 100644
View file @
00f555fb
<?php
declare
(
strict_types
=
1
);
namespace
App\Modules\SportsActivity\Controllers\Api
;
use
App\Core\Controller
;
use
App\Core\Request
;
use
App\Core\Response
;
use
App\Modules\SportsActivity\Services\PoolGridTemplateService
;
class
PoolGridTemplateApiController
extends
Controller
{
public
function
list
(
Request
$request
,
string
$id
)
:
Response
{
$templates
=
PoolGridTemplateService
::
getTemplates
((
int
)
$id
);
return
$this
->
json
([
'templates'
=>
$templates
]);
}
public
function
store
(
Request
$request
,
string
$id
)
:
Response
{
$body
=
$request
->
jsonBody
();
$name
=
trim
((
string
)
(
$body
[
'name'
]
??
''
));
$description
=
trim
((
string
)
(
$body
[
'description'
]
??
''
));
$color
=
trim
((
string
)
(
$body
[
'color'
]
??
'#3B82F6'
));
$entries
=
$body
[
'entries'
]
??
[];
if
(
!
$name
)
{
return
$this
->
json
([
'error'
=>
'اسم القالب مطلوب'
],
400
);
}
$result
=
PoolGridTemplateService
::
createTemplate
((
int
)
$id
,
$name
,
$description
?:
null
,
$color
,
$entries
);
return
$this
->
json
(
$result
,
$result
[
'success'
]
?
200
:
422
);
}
public
function
update
(
Request
$request
,
string
$id
,
string
$tid
)
:
Response
{
$body
=
$request
->
jsonBody
();
$name
=
trim
((
string
)
(
$body
[
'name'
]
??
''
));
$description
=
trim
((
string
)
(
$body
[
'description'
]
??
''
));
$color
=
trim
((
string
)
(
$body
[
'color'
]
??
'#3B82F6'
));
$entries
=
$body
[
'entries'
]
??
[];
if
(
!
$name
)
{
return
$this
->
json
([
'error'
=>
'اسم القالب مطلوب'
],
400
);
}
$db
=
\App\Core\App
::
getInstance
()
->
db
();
$ts
=
date
(
'Y-m-d H:i:s'
);
$db
->
update
(
'sa_pool_zone_templates'
,
[
'name'
=>
$name
,
'description'
=>
$description
?:
null
,
'color'
=>
$color
,
'updated_at'
=>
$ts
,
],
'id = ?'
,
[(
int
)
$tid
]);
// Replace entries
$db
->
delete
(
'sa_pool_zone_template_entries'
,
'template_id = ?'
,
[(
int
)
$tid
]);
foreach
(
$entries
as
$entry
)
{
$zoneJson
=
$entry
[
'zone_selection_json'
]
??
'{}'
;
if
(
is_array
(
$zoneJson
))
{
$zoneJson
=
json_encode
(
$zoneJson
,
JSON_UNESCAPED_UNICODE
);
}
$db
->
insert
(
'sa_pool_zone_template_entries'
,
[
'template_id'
=>
(
int
)
$tid
,
'day_of_week'
=>
(
int
)
(
$entry
[
'day_of_week'
]
??
0
),
'start_time'
=>
$entry
[
'start_time'
]
??
'09:00:00'
,
'end_time'
=>
$entry
[
'end_time'
]
??
'10:00:00'
,
'zone_selection_type'
=>
$entry
[
'zone_selection_type'
]
??
'all'
,
'zone_selection_json'
=>
$zoneJson
,
'assignment_type'
=>
$entry
[
'assignment_type'
]
??
'training'
,
'group_id'
=>
!
empty
(
$entry
[
'group_id'
])
?
(
int
)
$entry
[
'group_id'
]
:
null
,
'coach_id'
=>
!
empty
(
$entry
[
'coach_id'
])
?
(
int
)
$entry
[
'coach_id'
]
:
null
,
'label'
=>
$entry
[
'label'
]
??
$name
,
'notes'
=>
$entry
[
'notes'
]
??
null
,
'created_at'
=>
$ts
,
'updated_at'
=>
$ts
,
]);
}
return
$this
->
json
([
'success'
=>
true
]);
}
public
function
delete
(
Request
$request
,
string
$id
,
string
$tid
)
:
Response
{
$result
=
PoolGridTemplateService
::
deleteTemplate
((
int
)
$tid
);
return
$this
->
json
(
$result
,
$result
[
'success'
]
?
200
:
422
);
}
public
function
expand
(
Request
$request
,
string
$id
,
string
$tid
)
:
Response
{
$body
=
$request
->
jsonBody
();
$fromDate
=
trim
((
string
)
(
$body
[
'from_date'
]
??
''
));
$toDate
=
trim
((
string
)
(
$body
[
'to_date'
]
??
''
));
if
(
!
$fromDate
||
!
$toDate
)
{
return
$this
->
json
([
'error'
=>
'التواريخ مطلوبة'
],
400
);
}
if
(
$fromDate
>
$toDate
)
{
return
$this
->
json
([
'error'
=>
'تاريخ البداية يجب أن يكون قبل النهاية'
],
400
);
}
// Max 60 days to prevent accidental mass generation
$daysDiff
=
(
strtotime
(
$toDate
)
-
strtotime
(
$fromDate
))
/
86400
;
if
(
$daysDiff
>
60
)
{
return
$this
->
json
([
'error'
=>
'الحد الأقصى 60 يوم للتوسيع'
],
400
);
}
$result
=
PoolGridTemplateService
::
expandTemplate
((
int
)
$tid
,
$fromDate
,
$toDate
);
return
$this
->
json
(
$result
,
$result
[
'success'
]
?
200
:
422
);
}
public
function
rollback
(
Request
$request
,
string
$id
,
string
$tid
,
string
$rid
)
:
Response
{
$result
=
PoolGridTemplateService
::
rollbackRun
((
int
)
$rid
);
return
$this
->
json
(
$result
,
$result
[
'success'
]
?
200
:
422
);
}
}
app/Modules/SportsActivity/Routes.php
View file @
00f555fb
...
...
@@ -155,4 +155,12 @@ return [
[
'POST'
,
'/api/sa/pool-grid/{id:\d+}/clear'
,
'SportsActivity\Controllers\Api\PoolGridApiController@clear'
,
[
'auth'
,
'csrf'
],
'sa.pool-grid.manage'
],
[
'POST'
,
'/api/sa/pool-grid/{id:\d+}/update-grid'
,
'SportsActivity\Controllers\Api\PoolGridApiController@updateGrid'
,
[
'auth'
,
'csrf'
],
'sa.pool-grid.manage'
],
[
'POST'
,
'/api/sa/pool-grid/{id:\d+}/copy-slot'
,
'SportsActivity\Controllers\Api\PoolGridApiController@copySlot'
,
[
'auth'
,
'csrf'
],
'sa.pool-grid.manage'
],
// Pool Grid Templates
[
'GET'
,
'/api/sa/pool-grid/{id:\d+}/templates'
,
'SportsActivity\Controllers\Api\PoolGridTemplateApiController@list'
,
[
'auth'
],
'sa.pool-grid.manage'
],
[
'POST'
,
'/api/sa/pool-grid/{id:\d+}/templates'
,
'SportsActivity\Controllers\Api\PoolGridTemplateApiController@store'
,
[
'auth'
,
'csrf'
],
'sa.pool-grid.manage'
],
[
'POST'
,
'/api/sa/pool-grid/{id:\d+}/templates/{tid:\d+}'
,
'SportsActivity\Controllers\Api\PoolGridTemplateApiController@update'
,
[
'auth'
,
'csrf'
],
'sa.pool-grid.manage'
],
[
'POST'
,
'/api/sa/pool-grid/{id:\d+}/templates/{tid:\d+}/delete'
,
'SportsActivity\Controllers\Api\PoolGridTemplateApiController@delete'
,
[
'auth'
,
'csrf'
],
'sa.pool-grid.manage'
],
[
'POST'
,
'/api/sa/pool-grid/{id:\d+}/templates/{tid:\d+}/expand'
,
'SportsActivity\Controllers\Api\PoolGridTemplateApiController@expand'
,
[
'auth'
,
'csrf'
],
'sa.pool-grid.manage'
],
[
'POST'
,
'/api/sa/pool-grid/{id:\d+}/templates/{tid:\d+}/runs/{rid:\d+}/rollback'
,
'SportsActivity\Controllers\Api\PoolGridTemplateApiController@rollback'
,
[
'auth'
,
'csrf'
],
'sa.pool-grid.manage'
],
];
app/Modules/SportsActivity/Services/PoolGridService.php
View file @
00f555fb
This diff is collapsed.
Click to expand it.
app/Modules/SportsActivity/Services/PoolGridTemplateService.php
0 → 100644
View file @
00f555fb
This diff is collapsed.
Click to expand it.
app/Modules/SportsActivity/Views/pool-grid/manage.php
View file @
00f555fb
This diff is collapsed.
Click to expand it.
database/migrations/Phase_70_023_create_sa_pool_zone_templates_table.php
0 → 100644
View file @
00f555fb
<?php
declare
(
strict_types
=
1
);
return
[
'up'
=>
"CREATE TABLE `sa_pool_zone_templates` (
`id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`facility_id` BIGINT UNSIGNED NOT NULL,
`name` VARCHAR(200) NOT NULL,
`description` TEXT NULL,
`color` VARCHAR(20) NULL DEFAULT '#3B82F6',
`is_active` TINYINT(1) NOT NULL DEFAULT 1,
`created_by` BIGINT UNSIGNED NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX `idx_sa_pzt_facility` (`facility_id`, `is_active`),
CONSTRAINT `fk_sa_pzt_facility` FOREIGN KEY (`facility_id`) REFERENCES `sa_facilities`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
,
'down'
=>
"DROP TABLE IF EXISTS `sa_pool_zone_templates`;"
,
];
database/migrations/Phase_70_024_create_sa_pool_zone_template_entries_table.php
0 → 100644
View file @
00f555fb
<?php
declare
(
strict_types
=
1
);
return
[
'up'
=>
"CREATE TABLE `sa_pool_zone_template_entries` (
`id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`template_id` BIGINT UNSIGNED NOT NULL,
`day_of_week` TINYINT UNSIGNED NOT NULL COMMENT '0=Sunday...6=Saturday',
`start_time` TIME NOT NULL,
`end_time` TIME NOT NULL,
`zone_selection_type` VARCHAR(20) NOT NULL COMMENT 'cells, row, column, all',
`zone_selection_json` JSON NOT NULL,
`assignment_type` VARCHAR(20) NOT NULL COMMENT 'training, blocked, maintenance, hourly',
`group_id` BIGINT UNSIGNED NULL,
`coach_id` BIGINT UNSIGNED NULL,
`label` VARCHAR(200) NULL,
`notes` TEXT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX `idx_sa_pzte_template` (`template_id`),
INDEX `idx_sa_pzte_day` (`day_of_week`, `start_time`),
CONSTRAINT `fk_sa_pzte_template` FOREIGN KEY (`template_id`) REFERENCES `sa_pool_zone_templates`(`id`) ON DELETE CASCADE,
CONSTRAINT `fk_sa_pzte_group` FOREIGN KEY (`group_id`) REFERENCES `sa_groups`(`id`) ON DELETE SET NULL,
CONSTRAINT `fk_sa_pzte_coach` FOREIGN KEY (`coach_id`) REFERENCES `sa_coaches`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
,
'down'
=>
"DROP TABLE IF EXISTS `sa_pool_zone_template_entries`;"
,
];
database/migrations/Phase_70_025_create_sa_pool_zone_template_runs_table.php
0 → 100644
View file @
00f555fb
<?php
declare
(
strict_types
=
1
);
return
[
'up'
=>
"CREATE TABLE `sa_pool_zone_template_runs` (
`id` BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`template_id` BIGINT UNSIGNED NOT NULL,
`date_from` DATE NOT NULL,
`date_to` DATE NOT NULL,
`generated_count` INT UNSIGNED NOT NULL DEFAULT 0,
`skipped_count` INT UNSIGNED NOT NULL DEFAULT 0,
`status` VARCHAR(20) NOT NULL DEFAULT 'completed' COMMENT 'completed, rolled_back',
`rolled_back_at` TIMESTAMP NULL,
`rolled_back_by` BIGINT UNSIGNED NULL,
`created_by` BIGINT UNSIGNED NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
INDEX `idx_sa_pztr_template` (`template_id`),
CONSTRAINT `fk_sa_pztr_template` FOREIGN KEY (`template_id`) REFERENCES `sa_pool_zone_templates`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
,
'down'
=>
"DROP TABLE IF EXISTS `sa_pool_zone_template_runs`;"
,
];
database/migrations/Phase_70_026_add_template_run_id_to_pool_zone_bookings.php
0 → 100644
View file @
00f555fb
<?php
declare
(
strict_types
=
1
);
return
[
'up'
=>
"ALTER TABLE `sa_pool_zone_bookings`
ADD COLUMN `template_run_id` BIGINT UNSIGNED NULL AFTER `notes`,
ADD INDEX `idx_sa_pzb_run` (`template_run_id`);"
,
'down'
=>
"ALTER TABLE `sa_pool_zone_bookings`
DROP INDEX `idx_sa_pzb_run`,
DROP COLUMN `template_run_id`;"
,
];
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment