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
ec96e7ed
Commit
ec96e7ed
authored
Apr 08, 2026
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update 3 files via Son of Anton
parent
ef7860c0
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
172 additions
and
201 deletions
+172
-201
SpouseController.php
app/Modules/Spouses/Controllers/SpouseController.php
+93
-98
Spouse.php
app/Modules/Spouses/Models/Spouse.php
+35
-50
create.php
app/Modules/Spouses/Views/create.php
+44
-53
No files found.
app/Modules/Spouses/Controllers/SpouseController.php
View file @
ec96e7ed
This diff is collapsed.
Click to expand it.
app/Modules/Spouses/Models/Spouse.php
View file @
ec96e7ed
...
@@ -16,22 +16,18 @@ class Spouse extends Model
...
@@ -16,22 +16,18 @@ class Spouse extends Model
protected
static
array
$fillable
=
[
protected
static
array
$fillable
=
[
'member_id'
,
'spouse_order'
,
'full_name_ar'
,
'full_name_en'
,
'member_id'
,
'spouse_order'
,
'full_name_ar'
,
'full_name_en'
,
'national_id'
,
'passport_number'
,
'date_of_birth'
,
'age_years'
,
'age_months'
,
'national_id'
,
'passport_number'
,
'date_of_birth'
,
'
gender'
,
'nationality'
,
'religion'
,
'qualification_id
'
,
'
age_years'
,
'age_months'
,
'gender'
,
'nationality'
,
'religion
'
,
'occupation'
,
'work_address'
,
'work_phone'
,
'mobile'
,
'
qualification_id'
,
'
occupation'
,
'work_address'
,
'work_phone'
,
'mobile'
,
'marriage_date'
,
'join_date'
,
'classification'
,
'marriage_date'
,
'join_date'
,
'classification'
,
'addition_fee'
,
'
addition_fee'
,
'
fee_receipt_number'
,
'status'
,
'photo_path'
,
'fee_receipt_number'
,
'status'
,
'photo_path'
,
];
];
public
static
function
getForMember
(
int
$memberId
)
:
array
public
static
function
getForMember
(
int
$memberId
)
:
array
{
{
$db
=
App
::
getInstance
()
->
db
();
$db
=
App
::
getInstance
()
->
db
();
return
$db
->
select
(
return
$db
->
select
(
"SELECT s.*, q.name_ar as qualification_name
"SELECT * FROM spouses WHERE member_id = ? AND is_archived = 0 ORDER BY spouse_order ASC"
,
FROM spouses s
LEFT JOIN qualifications q ON q.id = s.qualification_id
WHERE s.member_id = ? AND s.is_archived = 0
ORDER BY s.spouse_order ASC"
,
[
$memberId
]
[
$memberId
]
);
);
}
}
...
@@ -51,45 +47,30 @@ class Spouse extends Model
...
@@ -51,45 +47,30 @@ class Spouse extends Model
return
self
::
countActiveForMember
(
$memberId
)
+
1
;
return
self
::
countActiveForMember
(
$memberId
)
+
1
;
}
}
public
static
function
nidExists
ForOtherMember
(
string
$nid
,
int
$excludeMemberI
d
,
?
int
$excludeSpouseId
=
null
)
:
?
array
public
static
function
nidExists
Elsewhere
(
string
$ni
d
,
?
int
$excludeSpouseId
=
null
)
:
?
array
{
{
$db
=
App
::
getInstance
()
->
db
();
$db
=
App
::
getInstance
()
->
db
();
// Check members table
$memberDup
=
$db
->
selectOne
(
$memberDup
=
$db
->
selectOne
(
"SELECT id, full_name_ar, membership_number FROM members WHERE national_id = ? AND i
d != ? AND i
s_archived = 0"
,
"SELECT id, full_name_ar, membership_number FROM members WHERE national_id = ? AND is_archived = 0"
,
[
$nid
,
$excludeMemberId
]
[
$nid
]
);
);
if
(
$memberDup
)
{
if
(
$memberDup
)
return
[
'type'
=>
'member'
,
'data'
=>
$memberDup
];
return
[
'type'
=>
'member'
,
'data'
=>
$memberDup
];
}
// Check spouses table
$sql
=
"SELECT s.id, s.full_name_ar, m.membership_number FROM spouses s JOIN members m ON m.id = s.member_id WHERE s.national_id = ? AND s.is_archived = 0"
;
$sql
=
"SELECT s.id, s.full_name_ar, s.member_id, m.membership_number
FROM spouses s
JOIN members m ON m.id = s.member_id
WHERE s.national_id = ? AND s.is_archived = 0"
;
$params
=
[
$nid
];
$params
=
[
$nid
];
if
(
$excludeSpouseId
)
{
if
(
$excludeSpouseId
)
{
$sql
.=
" AND s.id != ?"
;
$sql
.=
" AND s.id != ?"
;
$params
[]
=
$excludeSpouseId
;
$params
[]
=
$excludeSpouseId
;
}
}
$spouseDup
=
$db
->
selectOne
(
$sql
,
$params
);
$spouseDup
=
$db
->
selectOne
(
$sql
,
$params
);
if
(
$spouseDup
)
{
if
(
$spouseDup
)
return
[
'type'
=>
'spouse'
,
'data'
=>
$spouseDup
];
return
[
'type'
=>
'spouse'
,
'data'
=>
$spouseDup
];
}
// Check children table
$childDup
=
$db
->
selectOne
(
$childDup
=
$db
->
selectOne
(
"SELECT c.id, c.full_name_ar, c.member_id, m.membership_number
"SELECT c.id, c.full_name_ar, m.membership_number FROM children c JOIN members m ON m.id = c.member_id WHERE c.national_id = ? AND c.is_archived = 0"
,
FROM children c
JOIN members m ON m.id = c.member_id
WHERE c.national_id = ? AND c.is_archived = 0"
,
[
$nid
]
[
$nid
]
);
);
if
(
$childDup
)
{
if
(
$childDup
)
return
[
'type'
=>
'child'
,
'data'
=>
$childDup
];
return
[
'type'
=>
'child'
,
'data'
=>
$childDup
];
}
return
null
;
return
null
;
}
}
...
@@ -97,35 +78,39 @@ class Spouse extends Model
...
@@ -97,35 +78,39 @@ class Spouse extends Model
public
function
getClassificationLabel
()
:
string
public
function
getClassificationLabel
()
:
string
{
{
return
match
(
$this
->
classification
)
{
return
match
(
$this
->
classification
)
{
'working'
=>
'عضو
عامل'
,
'working'
=>
'
عامل'
,
'
dependent'
=>
'عضو تابع
'
,
'
seasonal'
=>
'موسمي
'
,
default
=>
$this
->
classification
,
default
=>
$this
->
classification
??
'عامل'
,
};
};
}
}
public
function
getStatusLabel
()
:
string
public
function
getStatusLabel
()
:
string
{
{
return
match
(
$this
->
status
)
{
return
match
(
$this
->
status
)
{
'active'
=>
'نشط'
,
'active'
=>
'نشط'
,
'inactive'
=>
'غير نشط'
,
'inactive'
=>
'غير نشط'
,
'separated'
=>
'منفصل'
,
'divorced'
=>
'مطلق/ة'
,
'deceased'
=>
'متوفى'
,
'deceased'
=>
'متوفى/ة'
,
default
=>
$this
->
status
,
'transferred'
=>
'منقول/ة'
,
default
=>
$this
->
status
??
''
,
};
};
}
}
public
function
getMemberName
()
:
string
/**
* Get the max number of spouses allowed based on member gender.
*/
public
static
function
getMaxSpouses
(
string
$memberGender
)
:
int
{
{
$db
=
App
::
getInstance
()
->
db
();
// Female member: max 1 husband
$row
=
$db
->
selectOne
(
"SELECT full_name_ar FROM members WHERE id = ?"
,
[
$this
->
member_id
]);
// Male member: max 4 wives (as per regulations)
return
$
row
[
'full_name_ar'
]
??
'—'
;
return
$
memberGender
===
'female'
?
1
:
4
;
}
}
public
function
getQualificationName
()
:
string
/**
* Get the required spouse gender based on member gender.
*/
public
static
function
getRequiredSpouseGender
(
string
$memberGender
)
:
string
{
{
if
(
!
$this
->
qualification_id
)
return
'—'
;
return
$memberGender
===
'female'
?
'male'
:
'female'
;
$db
=
App
::
getInstance
()
->
db
();
$row
=
$db
->
selectOne
(
"SELECT name_ar FROM qualifications WHERE id = ?"
,
[
$this
->
qualification_id
]);
return
$row
[
'name_ar'
]
??
'—'
;
}
}
}
}
\ No newline at end of file
app/Modules/Spouses/Views/create.php
View file @
ec96e7ed
This diff is collapsed.
Click to expand it.
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