Index: openacs-4/packages/contacts/tcl/contact-complaint-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-complaint-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/contacts/tcl/contact-complaint-procs.tcl 8 Aug 2005 21:52:10 -0000 1.1 +++ openacs-4/packages/contacts/tcl/contact-complaint-procs.tcl 9 Aug 2005 20:50:06 -0000 1.2 @@ -28,9 +28,9 @@ @param turnover @param percent @param description - @param supplier_id + @param supplier_id @param paid - @param object_id + @param object_id The object_id you are making the complaint } { if { [empty_string_p $complaint_id] } { @@ -59,4 +59,22 @@ # Insert extra information the table db_dml insert_complaint { } +} + +ad_proc -public contact::complaint::check_name { + -name:required + {-parent_id "-100"} + {-complaint_id ""} +} { + Check if the name you are giving to the complaint already exists, if it does returns 1 otherwise returns 0 + + @param name The name of the item to check + @param parent_id The id of the parent item_id if exist, using -100 by default + @param complaint_id To figure out if is a new item or a new revision. If it's a revision, return 0 +} { + if {![empty_string_p $complaint_id] } { + return 0 + } else { + return [db_string check_name { } -default 0] + } } \ No newline at end of file Index: openacs-4/packages/contacts/tcl/contact-complaint-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-complaint-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/contacts/tcl/contact-complaint-procs.xql 8 Aug 2005 21:52:10 -0000 1.1 +++ openacs-4/packages/contacts/tcl/contact-complaint-procs.xql 9 Aug 2005 20:50:06 -0000 1.2 @@ -23,5 +23,17 @@ + + + select + 1 + from + cr_items + where + name = :name + and parent_id = :parent_id + + +