".__('The name must not be empty').""; } else if ($name == db_get_value ('name', 'tagent_custom_fields', 'name', $name)) { echo "

".__('The name must be unique')."

"; } else { $result = db_process_sql_insert('tagent_custom_fields', array('name' => $name, 'display_on_front' => $display_on_front)); echo "

".__('Field successfully created')."

"; } } /* Update field */ if ($update_field) { /*Check if name field is empty*/ if( $name != "") { $values = array('name' => $name, 'display_on_front' => $display_on_front); $result = db_process_sql_update('tagent_custom_fields', $values, array('id_field' => $id_field)); } else { $result = false; } if ($result !== false) { echo "

".__('Field successfully updated')."

"; } else { echo "

".__('There was a problem modifying field')."

"; } } /* Delete field */ if ($delete_field) { $result = db_process_sql_delete('tagent_custom_fields', array('id_field' => $id_field)); if (!$result) echo "

".__('There was a problem deleting field')."

"; else echo "

".__('Field successfully deleted')."

"; } $fields = db_get_all_fields_in_table('tagent_custom_fields'); $table->width = '98%'; if ($fields) { $table->head = array (); $table->head[0] = __('Field'); $table->head[1] = __('Display on front').ui_print_help_tip (__('The fields with display on front enabled will be displayed into the agent details'), true); $table->head[2] = __('Actions'); $table->align = array (); $table->align[1] = 'center'; $table->align[2] = 'center'; $table->data = array (); } else { echo '
'. __('No fields defined') .'
'; } if($fields === false) $fields = array(); foreach ($fields as $field) { $data[0] = ''.$field['name'].''; if($field['display_on_front']) { $data[1] = html_print_image('images/tick.png', true); } else { $data[1] = html_print_image('images/delete.png', true); } $data[2] = '' . html_print_image("images/config.png", true, array("alt" => __('Edit'), "title" => __('Edit'), "border" => '0')) . ''; $data[2] .= '  ' . html_print_image("images/cross.png", true, array("alt" => __('Delete'), "title" => __('Delete'), "border" => '0')) . ''; array_push ($table->data, $data); } if($fields) html_print_table ($table); echo '
'; echo '
'; html_print_submit_button (__('Create field'), 'crt', false, 'class="sub next"'); echo '
'; echo '
'; ?>