Index: openacs-4/packages/acs-person/www/add-edit.tcl.sav =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-person/www/Attic/add-edit.tcl.sav,v diff -u -N --- openacs-4/packages/acs-person/www/add-edit.tcl.sav 24 Sep 2002 05:23:52 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,223 +0,0 @@ -# packages/contacts/www/add-edit.tcl - -ad_page_contract { - @author Jon Griffin jon@jongriffin.com - @creation-date 2002-01-11 - @cvs-id $Id: add-edit.tcl.sav,v 1.1 2002/09/24 05:23:52 jong Exp $ -} { - contact_id:integer,notnull,optional - {family_name ""} - {given_name ""} - {middle_name ""} - {formatted_name ""} - {preferred_given_name ""} - {affix ""} - {company_name ""} - {company_type_id ""} - {category_id ""} - {notes ""} -} -properties { - context_bar:onevalue -} - -set package_id [ad_conn package_id] - -# get the company types -# note make sure this is subsite aware. - -query company_types multilist "select company_type_name, company_type_id from company_types" -query categories multilist "select category_name, category_id from contact_categories" - - -if {[info exists contact_id]} { - ad_require_permission $contact_id write - set context_bar [ad_context_bar "Edit Contact"] -} else { - ad_require_permission $package_id create - set context_bar [ad_context_bar "New contact"] -} - -template::form create new_contact - -if {[template::form is_request new_contact] && [info exists contact_id]} { - - template::element create new_contact contact_id \ - -widget hidden \ - -datatype number \ - -value $contact_id - - db_1row contact_select { - select c.contact_id, - family_name, - given_name, - middle_name, - formatted_name, - preferred_given_name, - affix, - company_name, - company_type_id, - notes - from contacts c - where c.contact_id = :contact_id - } -} - -template::element create new_contact family_name \ - -datatype text \ - -label "Last Name" \ - -html { size 20 } \ - -value $family_name - -template::element create new_contact given_name \ - -datatype text \ - -label "First Name" \ - -html { size 10 } \ - -value $given_name - -template::element create new_contact middle_name \ - -datatype text \ - -label "Middle" \ - -html { size 30 } \ - -value $middle_name - -template::element create new_contact formatted_name \ - -datatype text \ - -label "Formatted Name" \ - -html { size 40 } \ - -value $formatted_name - -template::element create new_contact preferred_given_name \ - -datatype text \ - -label "Preferred Name" \ - -html { size 40 } \ - -value $preferred_given_name - -template::element create new_contact affix \ - -datatype text \ - -label "Affix" \ - -html { size 30 } \ - -value $affix - -template::element create new_contact company_name \ - -datatype text \ - -label "Company Name" \ - -html { size 40 } \ - -value $company_name - -template::element create new_contact company_type_id \ - -datatype text \ - -widget select \ - -label "Company Type" \ - -options $company_types \ - -value $company_type_id - - - -## category -template::element create new_contact category_id \ - -datatype text \ - -widget select \ - -label "Contact Category" \ - -options $categories \ - -value $category_id - -template::element create new_contact hr_add \ - -datatype text \ - -widget inform \ - -label "" \ - -value
- -if { [info exists contact_id] } { - set link "

Edit Addresses

" -} else { - set link "" -} - -template::element create new_contact address_link \ - -datatype text \ - -widget inform \ - -label "" \ - -value $link - -if { [info exists contact_id] } { - set phono_link "Edit Phones" -} else { - set phono_link "" -} - -template::element create new_contact phone_link \ - -datatype text \ - -widget inform \ - -label "" \ - -value $phono_link - -##address -#template::form::section new_contact "Address Info" - -####################################### -### start of processing of update/new -####################################### -## this will only update the contact part -## seperate functions are needed for phone/address - -if [template::form is_valid new_contact] { - set user_id [ad_conn user_id] - set peeraddr [ad_conn peeraddr] - - if [info exists contact_id] { - db_dml note_update { - update contacts - set family_name = :family_name, - given_name = :given_name, - middle_name = :middle_name, - formatted_name = :formatted_name, - preferred_given_name = :preferred_given_name, - affix = :affix, - company_name = :company_name, - company_type_id = :company_type_id, - category_id = :category_id, - notes = :notes - where contact_id = :contact_id - } -} else { - db_dml new_contact { - declare - id integer; - begin - id := contact.new ( - given_name => :given_name, - middle_name => :middle_name, - formatted_name => :formatted_name, - preferred_given_name => :preferred_given_name, - affix => :affix, - company_name => :company_name, - company_type_id => :company_type_id, - category_id => :category_id, - notes => :notes, - creation_user => :user_id, - creation_ip => :peeraddr, - context_id => :package_id - ); - - acs_permission.grant_permission( - object_id => id, - grantee_id => :user_id, - privilege => 'write' - ); - - acs_permission.grant_permission ( - object_id => id, - grantee_id => :user_id, - privilege => 'delete' - ); - end; - } -} - - ad_returnredirect "." -} - -ad_return_template - - -