Commit a659d773 authored by Frank Bergmann's avatar Frank Bergmann

- first round-trip editing of tickets working

parent 87958536
...@@ -335,6 +335,7 @@ SELECT im_category_new(11802, 'Software', 'Intranet Conf Item Type'); ...@@ -335,6 +335,7 @@ SELECT im_category_new(11802, 'Software', 'Intranet Conf Item Type');
SELECT im_category_new(11804, 'Process', 'Intranet Conf Item Type'); SELECT im_category_new(11804, 'Process', 'Intranet Conf Item Type');
SELECT im_category_new(11806, 'License', 'Intranet Conf Item Type'); SELECT im_category_new(11806, 'License', 'Intranet Conf Item Type');
SELECT im_category_new(11808, 'Specs', 'Intranet Conf Item Type'); SELECT im_category_new(11808, 'Specs', 'Intranet Conf Item Type');
SELECT im_category_new(11810, 'Service', 'Intranet Conf Item Type');
update im_categories set enabled_p = 'f' where category_id in (11804, 11808); update im_categories set enabled_p = 'f' where category_id in (11804, 11808);
-- reserved to 11849 -- reserved to 11849
......
...@@ -22,7 +22,7 @@ ad_proc -public im_conf_item_type_software {} { return 11802 } ...@@ -22,7 +22,7 @@ ad_proc -public im_conf_item_type_software {} { return 11802 }
ad_proc -public im_conf_item_type_process {} { return 11804 } ad_proc -public im_conf_item_type_process {} { return 11804 }
ad_proc -public im_conf_item_type_license {} { return 11806 } ad_proc -public im_conf_item_type_license {} { return 11806 }
ad_proc -public im_conf_item_type_specs {} { return 11808 } ad_proc -public im_conf_item_type_specs {} { return 11808 }
ad_proc -public im_conf_item_type_service {} { return 11810 }
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -43,6 +43,96 @@ ad_proc -private im_package_conf_items_id_helper {} { ...@@ -43,6 +43,96 @@ ad_proc -private im_package_conf_items_id_helper {} {
} }
namespace eval im_conf_item {
ad_proc -public new {
{ -var_hash "" }
} {
Create a new configuration item.
There are only few required field.
Primary key is conf_item_nr which defaults to conf_item_name.
@author frank.bergmann@project-open.com
@return The object_id of the new (or existing) Conf Item.
} {
array set vars $var_hash
set conf_item_new_sql "
select im_conf_item__new(
null,
'im_conf_item',
now(),
[ad_get_user_id],
'[ad_conn peeraddr]',
null,
:conf_item_name,
:conf_item_nr,
:conf_item_parent_id,
:conf_item_type_id,
:conf_item_status_id
)
"
# Set defaults.
set conf_item_name $vars(conf_item_name)
set conf_item_nr $conf_item_name
set conf_item_code $conf_item_name
set conf_item_parent_id ""
set conf_item_status_id [im_conf_item_status_active]
set conf_item_type_id [im_conf_item_type_hardware]
set conf_item_version ""
set conf_item_owner_id [ad_get_user_id]
set description ""
set note ""
# Override defaults
if {[info exists vars(conf_item_nr)]} { set conf_item_nr $vars(conf_item_nr) }
if {[info exists vars(conf_item_code)]} { set conf_item_code $vars(conf_item_nr) }
if {[info exists vars(conf_item_parent_id)]} { set conf_item_parent_id $vars(conf_item_parent_id) }
if {[info exists vars(conf_item_status_id)]} { set conf_item_status_id $vars(conf_item_status_id) }
if {[info exists vars(conf_item_type_id)]} { set conf_item_type_id $vars(conf_item_type_id) }
if {[info exists vars(conf_item_version)]} { set conf_item_version $vars(conf_item_version) }
if {[info exists vars(conf_item_owner_id)]} { set conf_item_owner_id $vars(conf_item_owner_id) }
if {[info exists vars(description)]} { set description $vars(description) }
if {[info exists vars(note)]} { set note $vars(note) }
# Check if the item already exists
set conf_item_id [db_string exists "
select conf_item_id
from im_conf_items
where
conf_item_parent_id = :conf_item_parent_id and
conf_item_nr = :conf_item_nr
" -default 0]
# Create a new item if necessary
if {!$conf_item_id} { set conf_item_id [db_string new $conf_item_new_sql] }
# Update the item with additional variables from the vars array
set sql_list [list]
foreach var [array names vars] {
if {$var == "conf_item_id"} { continue }
lappend sql_list "$var = :$var"
}
set sql "
update im_conf_items set
[join $sql_list ",\n"]
where conf_item_id = :conf_item_id
"
db_dml update_conf_item $sql
return $conf_item_id
}
}
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Generate generic select SQL for Conf Items # Generate generic select SQL for Conf Items
# to be used in list pages, options, ... # to be used in list pages, options, ...
......
...@@ -150,17 +150,13 @@ template::list::create \ ...@@ -150,17 +150,13 @@ template::list::create \
} }
conf_item_name { conf_item_name {
label "[lang::message::lookup {} intranet-confdb.Conf_Item_Name Name]" label "[lang::message::lookup {} intranet-confdb.Conf_Item_Name Name]"
link_url_eval {[export_vars -base new {conf_item_id {form_mode "display"}}]} display_template {
@conf_item_lines.indent;noquote@<a href=@conf_item_lines.conf_item_url;noquote@>@conf_item_lines.conf_item_name;noquote@</a>
}
} }
ip_address { ip_address {
label "[lang::message::lookup {} intranet-confdb.IP_Address IP-Address]" label "[lang::message::lookup {} intranet-confdb.IP_Address IP-Address]"
} }
win_workgroup {
label "[lang::message::lookup {} intranet-confdb.Workgroup Workgroup]"
}
win_userdomain {
label "[lang::message::lookup {} intranet-confdb.Domain Domain]"
}
conf_item_type { conf_item_type {
label "[lang::message::lookup {} intranet-confdb.Conf_Item_Type Type]" label "[lang::message::lookup {} intranet-confdb.Conf_Item_Type Type]"
} }
...@@ -185,6 +181,12 @@ template::list::create \ ...@@ -185,6 +181,12 @@ template::list::create \
} }
set ttt { set ttt {
win_workgroup {
label "[lang::message::lookup {} intranet-confdb.Workgroup Workgroup]"
}
win_userdomain {
label "[lang::message::lookup {} intranet-confdb.Domain Domain]"
}
conf_item_code { conf_item_code {
label "[lang::message::lookup {} intranet-confdb.Conf_Item_Code Code]" label "[lang::message::lookup {} intranet-confdb.Conf_Item_Code Code]"
} }
...@@ -216,21 +218,30 @@ set conf_item_sql [im_conf_item_select_sql \ ...@@ -216,21 +218,30 @@ set conf_item_sql [im_conf_item_select_sql \
set sql " set sql "
select i.*, select i.*,
tree_level(i.tree_sortkey)-1 as indent_level,
p.project_id, p.project_id,
project_name project_name
from ($conf_item_sql) i from ($conf_item_sql) i
LEFT OUTER JOIN acs_rels r ON (i.conf_item_id = r.object_id_two) LEFT OUTER JOIN acs_rels r ON (i.conf_item_id = r.object_id_two)
LEFT OUTER JOIN im_projects p ON (p.project_id = r.object_id_one) LEFT OUTER JOIN im_projects p ON (p.project_id = r.object_id_one)
order by
i.tree_sortkey
" "
db_multirow -extend {conf_item_chk return_url processor} conf_item_lines conf_items_lines $conf_item_sql { db_multirow -extend {conf_item_chk conf_item_url indent return_url processor} conf_item_lines conf_items_lines $sql {
set conf_item_chk "<input type=\"checkbox\" set conf_item_chk "<input type=\"checkbox\"
name=\"conf_item_id\" name=\"conf_item_id\"
value=\"$conf_item_id\" value=\"$conf_item_id\"
id=\"conf_items_list,$conf_item_id\">" id=\"conf_items_list,$conf_item_id\">"
set processor "${processor_num}x$processor_speed" set processor "${processor_num}x$processor_speed"
set return_url [im_url_with_query] set return_url [im_url_with_query]
set conf_item_url [export_vars -base new {conf_item_id {form_mode "display"}}]
set indent ""
for {set i 0} {$i < $indent_level} {incr i} {
append indent "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
}
} }
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