Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
intranet-rest
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
project-open
intranet-rest
Commits
528126e9
Commit
528126e9
authored
Nov 06, 2023
by
Frank Bergmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added attendance management
parent
717d6121
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
0 deletions
+88
-0
intranet-rest-create-procs.tcl
tcl/intranet-rest-create-procs.tcl
+88
-0
No files found.
tcl/intranet-rest-create-procs.tcl
View file @
528126e9
...
...
@@ -1668,6 +1668,94 @@ ad_proc -private im_rest_post_object_type_im_note {
}
# --------------------------------------------------------
# im_attendance_interval
#
ad_proc -private im_rest_post_object_type_im_attendance_interval
{
{
-format
"json"
}
{
-rest_user_id 0
}
{
-rest_otype
""
}
{
-rest_otype_pretty
"Attendance"
}
{
-rest_oid
""
}
{
-content
""
}
{
-debug 0
}
}
{
Handler for POST calls on particular im_attendance_interval objects.
}
{
ns_log Notice
"im_rest_post_object_im_attendance_interval: rest_oid=
$rest
_oid"
# Permissions
set add_p
[
im_permission
$rest
_user_id
"add_attendances"
]
if
{
!$add_p
}
{
return
[
im_rest_error -format
$format
-http_status 403 -message
"User #
$rest
_user_id does not have the right to create attendances"
]
}
set creation_user
$rest
_user_id
set creation_ip
[
ad_conn peeraddr
]
# Extract a key-value list of variables from JSON POST request
array set hash_array
[
im_rest_parse_json_content -rest_otype
$rest
_otype -format
$format
-content
$content
]
ns_log Notice
"im_rest_post_object_type_
$rest
_otype: hash_array=
[
array
get hash_array
]
"
# write hash values as local variables
foreach key
[
array
names hash_array
]
{
set value
$hash
_array
(
$key
)
ns_log Notice
"im_rest_post_object_type_
$rest
_otype: key=
$key
, value=
$value
"
set
$key
$value
}
# Check that all required variables are there
set required_vars
{
attendance_user_id attendance_start attendance_end attendance_status_id attendance_type_id
}
foreach var
$required
_vars
{
if
{
!
[
info
exists
$var
]}
{
return
[
im_rest_error -format
$format
-http_status 406 -message
"Variable '
$var
' not specified. The following variables are required:
$required
_vars"
]
}
}
# Check for duplicate
set dup_sql
"
select count(*)
from im_attendance_intervals
where attendance_user_id = :attendance_user_id and
attendance_start = :attendance_start and
attendance_end = :attendance_end
"
if
{[
db_string duplicates
$dup
_sql
]}
{
return
[
im_rest_error -format
$format
-http_status 406 -message
"Duplicate
$rest
_otype_pretty: The attendance already exists for the specified object."
]
}
if
{[
catch
{
set rest_oid
[
db_string new_im_attendance_interval
"
select im_attendance_interval__new (
null, -- attendance_id
:rest_otype, -- object_type
now(), -- creation_date
:creation_user,
:creation_ip,
null, -- context_id
:attendance_user_id,
:attendance_start,
:attendance_end,
:attendance_status_id,
:attendance_type_id,
:attendance_note
)
"
]
}
err_msg
]}
{
ns_log Error
"Error creating
$rest
_otype: '
$err
_msg'"
return
[
im_rest_error -format
$format
-http_status 406 -message
"Error creating
$rest
_otype_pretty: '
$err
_msg'."
]
}
im_audit -user_id
$rest
_user_id -object_type
$rest
_otype -object_id
$rest
_oid -status_id
$attendance
_status_id -type_id
$attendance
_type_id -action after_create
set hash_array
(
rest_oid
)
$rest
_oid
set hash_array
(
rel_id
)
$rest
_oid
return
[
array
get hash_array
]
}
# --------------------------------------------------------
# Membership Relationshiop
...
...
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