insert_submit_name; $submitvalue = "e n t e r c o n t a c t"; $name_html_after = ''; break; case 'edit': $submitname = $this->edit_submit_name; $submitvalue = "s u b m i t c h a n g e s"; $name_html_after = 'Do not use this to enter a new contact'; break; } // switch $this->fields = array( 'name' => array( 'label' => 'Name', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 30, 'char_max' => 100 ), 'html_after' => $name_html_after ), 'address' => array( 'label' => 'Address', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 30, 'char_max' => 100 ) ), 'city' => array( 'label' => 'City', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 20, 'char_max' => 50 ) ), 'state' => array( 'label' => 'State', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 10, 'char_max' => 50 ) ), 'postal' => array( 'label' => 'Zip code', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 10, 'char_max' => 20 ) ), 'country' => array( 'label' => 'Country', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 20, 'char_max' => 50 ) ), 'phone' => array( 'label' => 'Phone', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 10, 'char_max' => 20 ) ), 'fax' => array( 'label' => 'Fax', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 10, 'char_max' => 20 ) ), 'email' => array( 'label' => 'Email', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 30, 'char_max' => 100 ), 'validation' => array('email') ), 'local_signup' => array( 'label' => 'Signup Type', 'label_css' => 'black_11_bold', 'type' => array( 'tag' => 'select', 'options' => array('yes'=>'Store','no'=>'Web'), 'top_option' => array(), ), 'default' => 'yes' ), 'birthday' => array( 'label' => 'Birthday (mmddyy)', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 6, 'char_max' => 6 ) ), 'email_list' => array( 'label' => 'On Email List (select yes to sign up)', 'label_css' => 'black_11_bold', 'type' => array( 'tag' => 'select', 'options' => array('yes'=>'yes','no'=>'no'), 'top_option' => array(), ), 'default' => 'no' ), 'mailing_list' => array( 'label' => 'On Mailing List (select yes to sign up)', 'label_css' => 'black_11_bold', 'type' => array( 'tag' => 'select', 'options' => array('yes'=>'yes','no'=>'no'), 'top_option' => array(), ), 'default' => 'no' ), 'top_size' => array( 'label' => 'Top Size', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 20, 'char_max' => 50 ) ), 'bottom_size' => array( 'label' => 'Bottom Size', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 20, 'char_max' => 50 ) ), 'notes' => array( 'label' => 'Our Notes', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'textarea', 'rows' => 5, 'cols' => 50 ) ), 'notes_contact' => array( 'label' => 'Contact Comments', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'textarea', 'rows' => 5, 'cols' => 50, 'disabled' => TRUE ) ), $submitname => array( 'type' => array( 'tag'=> 'input_submit', ), 'input_css' => 'blue_submit', 'default' => $submitvalue, ) ); if($form_type == 'insert') { $this->fields['create_date'] = array( 'type' => array( 'tag' => 'input_hidden' ), 'default' => 'NOW()' ); $this->fields['id'] = array( 'type' => array( 'tag' => 'input_hidden' ), 'default' => 'NULL()' ); } else { $this->fields['name']['disabled'] = FALSE; } if($db_default) { foreach($this->fields as $fieldName=>$fieldInfo) { $exclude_fields = array(); if(!in_array($fieldName, $exclude_fields) && $fieldInfo['type']['tag'] != 'input_submit' && $fieldInfo['type']['tag'] != 'input_hidden') { $default = $db_fields[$fieldName]; $this->fields[$fieldName]['default'] = $default; } } } } function set_search_fields($type='contacts', $Forms='', $Designers='') { $this->search_fields = array( 'name' => array( 'label' => 'Name [ie Hillary% or %Clinton]', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 20, 'char_max' => 50 ) ), 'city' => array( 'label' => 'City', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 30, 'char_max' => 100 ) ), 'state' => array( 'label' => 'State', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 5, 'char_max' => 50 ) ), 'postal' => array( 'label' => 'Zip Code', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 10, 'char_max' => 20 ) ), 'email' => array( 'label' => 'Email', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 30, 'char_max' => 100 ) ), 'notes' => array( 'label' => 'Notes [ie %search term%]', 'label_css' => 'black_11_bold', 'type' => array( 'tag'=> 'input_text', 'input_size' => 50, 'char_max' => 255 ) ) ); if($type == 'customers') { $onchange = 'location.href=\''.$_SERVER['PHP_SELF'].'?&designer_id=\'+this.value'; // designer select $this->search_fields['designer_id'] = array( 'label' => 'Designer', 'label_css' => 'black_11_bold', 'type' => array( 'tag' => 'predefined', 'class' => 'Designers', 'function' => 'generate_select', 'args' => array('Forms'=>$Forms, 'name'=>'designer_id', 'RS'=>$Designers->get_RecordSet('ContactsAdmin::set_search_fields'), 'onchange'=>$onchange, 'top_option'=>array(''=>' -- select -- '), 'selected'=>'', 'css'=>'') ) ); } $this->search_fields['sub'] = array( 'type' => array( 'tag'=> 'input_submit', ), 'input_css' => 'blue_submit', 'default' => 'e n t e r', ); } function _insert($TestimonialForm) { $ins = "INSERT INTO $this->db_table ("; $i = 0; $ins_val = " VALUES("; foreach($TestimonialForm->fields as $field_name => $field_info) { ++$i; if($field_name != $this->insert_submit_name) { $ins .= $field_name.','; switch($field_name) { case 'enter_date': $ins_val .= 'NOW(),'; break; default: $ins_val .= "'".trim(addslashes($field_info['value']))."',"; } } } $ins = substr($ins, 0, strlen($ins)-1) . ')'; $ins_val = substr($ins_val, 0, strlen($ins_val)-1) . ')'; $insert = $ins.$ins_val; //echo $insert; if(!$t_id = Database::ado_execute_query($insert, 'TestimonialAdmin::_insert')) { return(FALSE); } else { Utilities::notify(Config::$tech_email, 'Testimonial Inserted', $t_id); return($t_id); } } function _update($TestimonialForm, $testimonial_id) { $upd = "UPDATE $this->db_table SET"; $i = 0; foreach($TestimonialForm->fields as $field_name => $field_info) { ++$i; if($field_info['type']['tag'] != 'input_submit' && $field_info['type']['tag'] != 'input_hidden') { switch($field_name) { default: $upd .= " $field_name='".trim(addslashes($field_info['value']))."',"; } } } $upd = substr($upd, 0, strlen($upd)-1) . " WHERE id='".$testimonial_id."' LIMIT 1"; //echo $upd; $affected_rows = Database::ado_execute_query($upd, 'TestimonialAdmin::_update'); if($affected_rows === FALSE) { return(FALSE); } else { Utilities::notify(Config::$tech_email, 'Testimonial Updated', $upd); return(TRUE); } } // update } ?>