Commit 2af09b64 authored by Frank Bergmann's avatar Frank Bergmann

Implemented automatic generation of absence title from template

parent f56c0b8b
......@@ -8,7 +8,7 @@
<singleton-p>t</singleton-p>
<auto-mount>intranet-timesheet2</auto-mount>
<version name="5.1.0.0.0" url="https://www.project-open.net/download/apm/intranet-timesheet2-5.1.0.0.0.apm">
<version name="5.1.0.0.1" url="https://www.project-open.net/download/apm/intranet-timesheet2-5.1.0.0.1.apm">
<owner url="mailto:frank.bergmann@project-open.com">Frank Bergmann</owner>
<release-date>2004-02-07</release-date>
<vendor url="https://www.project-open.com/">]project-open[</vendor>
......@@ -70,6 +70,7 @@
<parameter scope="instance" datatype="number" min_n_values="1" max_n_values="1" name="TimesheetProjectNameMaxLength" default="50" description="Should we cut down the name of a task or ticket in the timesheet entry page to a maximum size? Default is 50, 0 disables this feature."/>
<parameter scope="instance" datatype="number" min_n_values="1" max_n_values="1" name="TimesheetProjectNrMaxLength" default="12" description="Should we cut down the nr (short name) of a task or ticket in the timesheet entry page to a maximum size? Default is 12, 0 disables this feature."/>
<parameter scope="instance" datatype="string" min_n_values="1" max_n_values="1" name="CustomHoursActionHashFunction" default="" description="Hook/callback in intranet-timesheet2/new-2 function to perform on the 'action hash' of update/delete/create actions resulting from the entry of hours by the user. For example, cosine has a 'im_cust_cosine_veto_action_hash' custom function to veto entries if prices are not set correctly. "/>
<parameter datatype="number" min_n_values="1" max_n_values="1" name="AbsenceAutogenerateTitleTemplate" default="" description="Should the system automatically generate the title of an absence? An non-empty string will be treated as a template, you can use the variables absence_id, absence_type, absence_owner, absence_start_date and absence_end_date at the moment, prefixed by a dollar so that it can be evaluated as a string using TCL 'eval'. Example (without single quotes): '$absence_type from $absence_start_date to $absence_end_date by $absence_owner'"/>
</parameters>
</version>
</package>
......@@ -46,6 +46,10 @@ set absence_type [lang::message::lookup "" intranet-timesheet2.Absence "Absence"
set duration_default_uom [parameter::get_from_package_key -package_key "intranet-timesheet2" -parameter "AbsenceDefaultDurationUnit" -default "days"]
# Autogenerate the absence title using a template?
# absence_id, absence_type, absence_user, absence_start_date and absence_end_date at the moment, prefixed by a dollar so that it can be evaluated as a string using TCL 'eval'."/>
# set autogenerate_title_default {$absence_type $absence_start_date bis $absence_end_date von $absence_owner}
set autogenerate_title_template [parameter::get_from_package_key -package_key "intranet-timesheet2" -parameter "AbsenceAutogenerateTitleTemplate" -default ""]
# Custom redirect? You should change all links to this
# page to the new URL, but sometimes you miss links...
......@@ -238,9 +242,20 @@ if {[info exists absence_id]} {
set form_fields {
absence_id:key
{absence_owner_id:text(hidden),optional}
{absence_name:text(text) {label "[_ intranet-timesheet2.Absence_Name]"} {html {size 40}}}
}
# Should we autogenerate the title?
# ad_return_complaint 1 $autogenerate_title_template
if {"" eq $autogenerate_title_template} {
# No autogeneration, just add the field
# {absence_name:text(text) {label "[_ intranet-timesheet2.Absence_Name]"} {html {size 40}}}
lappend form_fields "absence_name:text(text) {label \"[_ intranet-timesheet2.Absence_Name]\"} {html {size 40}}"
} else {
# Autogeneration, add a hidden field
lappend form_fields "absence_name:text(hidden) {label \"[_ intranet-timesheet2.Absence_Name]\"} {html {size 40}}"
}
# -------
# By setting RequireAbsenceTypeInUrlP to '1' an 'Absence Type' can be set only by passing
# the respective absence_type_id as an URL parameter.
......@@ -368,6 +383,14 @@ ad_form -extend -name absence -on_request {
if { $current_user_id != $user_id_from_search && ![im_permission $current_user_id "add_absences_all"] } {
set user_id_from_search $current_user_id
}
# Autogenerate the absence_name
if {"" ne $autogenerate_title_template} {
set absence_owner [im_name_from_user_id $absence_owner_id]
set absence_start_date [string map {" " "-"} $start_date]
set absence_end_date [string map {" " "-"} $end_date]
set absence_name [eval "set a \"$autogenerate_title_template\""]
}
} -select_query {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment