⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ticket_fields.php

📁 jsp程序开发系统
💻 PHP
📖 第 1 页 / 共 4 页
字号:
		for (value = 0; value < document.fields.multiselect.length; value++)
		{
			if (document.fields.multiselect[value].checked == true)
			{
				yesno = document.fields.multiselect[value].value;
			}
		}

		if (yesno == '1') {
			document.fields.maxoptions.disabled=false;
			document.fields.minoptions.disabled=false;
			document.fields.required[0].disabled=true;
			document.fields.required[1].disabled=true;
			document.fields.extrainput[1].checked=true;
			extrainput2();
			document.fields.extrainput[0].disabled=true;
		} else {
			document.fields.maxoptions.disabled=true;
			document.fields.minoptions.disabled=true;
			document.fields.required[0].disabled=false;
			document.fields.required[1].disabled=false;
			document.fields.extrainput[0].disabled=false;

		}

	}

	extrainput2();
	multipleselect();
	</SCRIPT>
	<?

	############################### CHECKBOX ############################### 
	} elseif ($user_field[formtype] == "checkbox") {

	echo form_hidden('formtype', 'checkbox');

	// regex
	$table[] = array('<b>Maximum Options</b><br />The maximum amount of options that can be selected. (Set a 0 to have no maximum.)', form_input('maxoptions', $user_field[maxoptions], '3'));
	$table[] = array('<b>Minimum Options</b><br />The minimum amount of options that must be selected. (Set as 0 to require no minimum number of options.)', form_input('minoptions', $user_field[minoptions], '3'));
	$table[] = array('<b>Error Message</b><br />The error message to be displayed if the user does not select an option. If you are enabling the extra INPUT field and have a custom regex which is not satisfied then this message would then be displayed.', $error);

	$width = array('60%', '40%');
	table_header('Field Criteria');
	table_content('', $table, '', '', '', '', $width);
	table_footer();
	unset($table, $width);

	// display properties
	$table[] = array('<b>Order</b><br />What order you wish the field to be displayed in relation to your other fields?', form_input('displayorder', $user_field[displayorder], '3'));
	$table[] = array('<b>Checkboxes Per line</b><br />How many checkboxes do you want to display per line?', form_input('perline', $user_field[perline], '3'));

	$width = array('60%', '40%');
	table_header('Field Display Properties');
	table_content('', $table, '', '', '', '', $width);
	table_footer();
	unset($table, $width);

	$field_data = unserialize($user_field[data]);

	// get max number for creating new fields
	if (is_array($field_data)) {
		while (list ($key, $val) = each ($field_data)) {
			$array_count[] = $field_data[$key][0];
		}
		$max = max($array_count);
		reset($field_data);
	}

	$field_data[] = array($max+1, '', '', '', '');
	$field_data[] = array($max+2, '', '', '', '');
	$field_data[] = array($max+3, '', '', '', '');
	$field_data[] = array($max+4, '', '', '', '');
	$field_data[] = array($max+5, '', '', '', '');

	while (list ($key, $val) = each ($field_data)) {

		$table[] = array(
				$val[0] . form_hidden($key, '1', $arrayto='elementid'),
				form_input($val[0], $val[1], '3', 'order'), 
				iff($val[2], "<B>$val[2]</B>", "<I>n/a</I>"),
				form_input($val[0], $val[2], '45', 'name'),
				form_radio_yn($val[0], 'start', $val[3])
			);
	}

	$columns = array('ID', 'Order', 'Current Value', 'New / Edit Value', 'Select by Default');
	table_header('Field Data');
	table_content($columns, $table);
	table_footer();
	unset($table);

	############################### SYSTEM ############################### 
	} elseif ($user_field[formtype] == "system") {

	$field_data = unserialize($user_field[data]);

	echo form_hidden('formtype', 'system');

	// creation time
	$table[] = array('<b>Run during registration (page 1)</b><br />Do you wish the code to be executed during the 1st page of user regisration whereupon the variable will be passed as a hidden form element to the 2nd page and then saved?', form_radio_yn('reg1', '', $field_data[when][reg1]));
	$table[] = array('<b>Run during registration (page 2)</b><br />Do you wish the code to be executed during the 2nd page of registration?', form_radio_yn('reg2', '', $field_data[when][reg2]));
	$table[] = array('<b>Run during user profile modification</b><br />Do you wish the code to be executed when a user modifies their profile?', form_radio_yn('usermod', '', $field_data[when][usermod]));
	$table[] = array('<b>Run during tech profile modification</b><br />Do you wish the code to be executed when a tech modifies a users profile?', form_radio_yn('techmod', '', $field_data[when][techmod]));	
	$table[] = array('<b>Run during tech user creation</b><br />Do you wish the code to be executed when a tech creates a user?', form_radio_yn('technew', '', $field_data[when][technew]));	

	$width = array('60%', '40%');
	table_header('Run Time');
	table_content('', $table, '', '', '', '', $width);
	table_footer();
	unset($table, $width);

	$table[] = array('<b>Code</b><br />Any PHP code you wish to run (to manipulate a variable)', form_textarea('code', '70', '5', $field_data[code][code]));	
	$table[] = array('<b>Variable</b><br />The variable you wish to store for this field', form_input('variable', $field_data[code][variable], '45'));	

	$width = array('60%', '40%');
	table_header('Code');
	table_content('', $table, '', '', '', '', $width);
	table_footer();
	unset($table, $width);


	}


	// show different form button if new/edit
	if ($_REQUEST['do'] == "edit") {
		echo "<br /><center><input type=\"submit\" name=\"submit\" value=\"Update Field Options\"></center></form>";
	} else {
		echo "<br /><center><input type=\"submit\" name=\"submit\" value=\"Create New Field\"></center></form>";
	}

}

############################### SELECT TYPE OF NEW FIELD TO CREATE ###############################

if ($_REQUEST['do'] == "add") {

	$table[] = array('<b>INPUT</b>', 'This field allows the user to enter text on one line. Useful for words and short sentances', '<a href="ticket_fields.php?do=new2&type=input">create</a>');
	$table[] = array('<b>TEXTAREA</b>', 'Allows for text input across a number of lines. Useful for where more information is required.', '<a href="ticket_fields.php?do=new2&type=textarea">create</a>');
	$table[] = array('<b>SELECT</b>', 'This field allows the user to select from a number of options contained in a list',  '<a href="ticket_fields.php?do=new2&type=select">create</a>');
	$table[] = array('<b>RADIO</b>', 'Allows the user from pick one from a number of options where the options are displayed as radio buttons',  '<a href="ticket_fields.php?do=new2&type=radio">create</a>');
	$table[] = array('<b>CHECKBOX</b>', 'Allows the user to select a number of options where the options are displayed as checkboxes',  '<a href="ticket_fields.php?do=new2&type=checkbox">create</a>');

	table_header('Create New Field');
	table_content('', $table);
	table_footer();
	unset($table, $width);

}

############################### DELETE CUSTOM PROFILE FIELDS ###############################
if ($_REQUEST['do'] == "delete") {

	$field = $db->query_return("SELECT name FROM ticket_def WHERE id = " . intval($id));

	// delete the field and column
	$db->query("DELETE FROM ticket_def WHERE id = " . intval($id));
	$db->query("ALTER TABLE ticket DROP $field[name]");

	// Update tech's field display preference; remove this deleted field from it.
	$techs = $db->query_return_array('SELECT id, fielddisplay FROM tech');
	if ($db->num_rows()) {
		foreach ($techs AS $tech) {
			$tech['fielddisplay'] = unserialize($tech['fielddisplay']);
			if (!@count($tech['fielddisplay']['custom'])) {
				// Tech has no preference here, move on.
				continue;
			}
			$tech['fielddisplay']['custom'] = array_diff($tech['fielddisplay']['custom'], array($id));
			$tech['fielddisplay'] = serialize($tech['fielddisplay']);
			$db->query("UPDATE tech SET fielddisplay = '" . mysql_escape_string($tech['fielddisplay']) . "' WHERE id = $tech[id]");
		}
	}
		
	

	jump('ticket_fields.php?action=view', 'Custom Profile Field Deleted');

}

############################### LIST CUSTOM PROFILE FIELDS ###############################
if ($_REQUEST['do'] == "view") {

	// Fetch indexes
	$db->query("SHOW INDEX FROM ticket");
	while ($index = $db->row_array()) {
		$indexed[$index['Column_name']] = 1;
	}

	// select the articles
	$db->query("
	SELECT * FROM ticket_def
	ORDER BY displayorder
	");
	
	while ($ticket_fields = $db->row_array()) {

		$ticket_fields[display_name] = unserialize($ticket_fields[display_name]);
		$ticket_fields[display_name] = $ticket_fields[display_name][$settings[default_language]];

		if ($indexed[$ticket_fields['name']]) {
			$index = jprompt('This will remove the index for this field. Searches on this field may take longer, but changes to the tickets table that involve this field may be faster after this change. This operation may take some time if there are many tickets.', 
				"ticket_fields.php?do=dropindex&id=$ticket_fields[id]",
				'Remove Index');
		} else {
			$index = jprompt('This will create an index for this field. Searches on this field may be faster, but changes to the tickets table that involve this field may take longer after this change. This operation may take some time if there are many tickets.', 
				"ticket_fields.php?do=createindex&id=$ticket_fields[id]",
				'Create Index');
		}

		${"table_$ticket_fields[formtype]"}[] = array(
			$ticket_fields[display_name], 
			$ticket_fields[name], 
			ifynb($ticket_fields[user_viewable]),
			ifynb($ticket_fields[user_editable]),
			ifynb($ticket_fields[tech_viewable]),
			ifynb($ticket_fields[tech_editable]),
			$index,
			$ticket_fields[displayorder], 
			"<a href=\"ticket_fields.php?do=edit&id=$ticket_fields[id]\">edit</a>",
			jprompt('Are you sure you want to delete this custom field?', "ticket_fields.php?do=delete&id=$ticket_fields[id]", 'Delete')
		);	

	}

	// build the row headings
	$columns = array('Display name', 'SQL name', 'User Viewable', 'User Editable', 'Tech Viewable', 'Tech Editable', 'Index', 'Order', 'Edit', 'Delete');

	table_header('Input Fields');
	table_content($columns, $table_input);
	table_footer();

	table_header('Select Fields');
	table_content($columns, $table_select);
	table_footer();

	table_header('Textarea Fields');
	table_content($columns, $table_textarea);
	table_footer();

	table_header('Radio Fields');
	table_content($columns, $table_radio);
	table_footer();

	table_header('Checkbox Fields');
	table_content($columns, $table_checkbox);
	table_footer();

	$columns = array('Display name', 'SQL name', 'User Viewable', 'Tech Viewable', 'Order', 'Edit', 'Delete');

	/*
	table_header('System Fields');
	table_content($columns, $table_system);
	table_footer();
	*/

}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -