Commit a7ef47ed authored by stage's avatar stage

Cleaned up new callback hook and moved cosine function to parameters

parent abd52e0b
......@@ -67,12 +67,9 @@
<parameter datatype="string" min_n_values="1" max_n_values="1" name="AbsenceDefaultDurationUnit" default="days" description="How should users enter absence duration by default? Options are 'days' or 'hours'. The days are multiplied with 8.0 in order to get hours. Default is 'days'."/>
<parameter scope="instance" datatype="number" min_n_values="1" max_n_values="1" name="TimesheetNoteTextareaRows" default="1" description="Should we show a textarea instead of a textbox field? '0' means standard text input. '1' means showing a textarea with 1 row, which is similar to a textbox, but allows resizing. Values > 1 will show bigger textareas. Default is '1' for showing a (resizable) textarea with 1 row."/>
<parameter scope="instance" datatype="string" min_n_values="1" max_n_values="1" name="TimesheetRedirectPackageUrl" default="" description="Use a custom implementation of intranet-timesheet2? Default is '' (empty string), in order to use the standard implementation. A value of '/intranet-cust-custname/timesheet' (no trailing slash '/'!) would redirect to a custom implementation in ~/packages/intranet-cust-custname/www/timesheet/."/>
<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. "/>
</parameters>
</version>
</package>
......@@ -356,9 +356,31 @@ foreach j $weekly_logging_days {
#ns_log Notice "hours/new2: day=$i, database_hours_hash=[array get database_hours_hash]"
#ns_log Notice "hours/new2: day=$i, screen_hours_hash=[array get screen_hours_hash]"
#ns_log Notice "hours/new2: day=$i, action_hash=[array get action_hash]"
ns_log Notice "hours/new2: day=$i, action_hash=[array get action_hash]"
# ----------------------------------------------------------
# Custom validation of action_hash
# Allows to veto entry of certain hours
set cust_action_hash_function [parameter::get -package_id [apm_package_id_from_key intranet-timesheet2] -parameter "CustomHoursActionHashFunction" -default ""]
if {"" ne $cust_action_hash_function} {
if {[catch {
set cust_action_hash_function_result [$cust_action_hash_function -user_id $user_id_from_search -julian_date $day_julian -action_hash_list [array get action_hash]]
} err_msg]} {
ad_return_complaint 1 "<b>Error executing custom function</b>:<br>
Function: <pre>$cust_action_hash_function -action_hash \[array get action_hash\]</pre><br>
Error: <pre>$err_msg</pre><br>
Stack: <pre>[ad_print_stack_trace]</pre>
"
ad_script_abort
}
}
# ad_return_complaint 1 "hours/new2: day=$i, action_hash=[array get action_hash]"
# ad_script_abort
# ----------------------------------------------------------
# Execute the actions
foreach project_id [array names action_hash] {
if {$wf_installed_p} {
......@@ -620,7 +642,7 @@ if {!$performance_mode_p} {
}
# ad_return_complaint 1 "action_hash=[array get action_hash], mod=[array get modified_projects_hash], all=$all_project_ids"
# ad_return_complaint 1 "action_hash=[array get action_hash],<br>mod=[array get modified_projects_hash],<br>all=$all_project_ids"
# Create cost items for every logged hours?
......@@ -634,7 +656,6 @@ if {$sync_cost_item_immediately_p} {
im_timesheet_update_timesheet_cache -project_id $project_id
# Create timesheet cost_items for all modified projects
im_timesheet2_sync_timesheet_costs -project_id $project_id
}
# Fraber 140103: !!!
......
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