priority.php
上传用户:gzy2002
上传日期:2010-02-11
资源大小:1785k
文件大小:11k
- <?php
- // +-------------------------------------------------------------+
- // | DeskPRO v [2.0.1 Production]
- // | Copyright (C) 2001 - 2004 Headstart Solutions Limited
- // | Supplied by WTN-WDYL
- // | Nullified by WTN-WDYL
- // | Distribution via WebForum, ForumRU and associated file dumps
- // +-------------------------------------------------------------+
- // | DESKPRO IS NOT FREE SOFTWARE
- // +-------------------------------------------------------------+
- // | License ID : Full Enterprise License =) ...
- // | License Owner : WTN-WDYL Team
- // +-------------------------------------------------------------+
- // | $RCSfile: priority.php,v $
- // | $Date: 2004/02/10 01:34:25 $
- // | $Revision: 1.30 $
- // +-------------------------------------------------------------+
- // | File Details:
- // | - Priorities maintenance (administration interface)
- // +-------------------------------------------------------------+
- error_reporting(E_ALL & ~E_NOTICE);
- require_once('./global.php');
- //Nullify WTN-WDYL Team
- // default do
- $_REQUEST['do'] = trim($_REQUEST['do']);
- if (!isset($_REQUEST['do']) or $_REQUEST['do'] == "") {
- $_REQUEST['do'] = "view";
- }
- // globalise variables
- $global = array (
- array('id', 'number')
- );
- rg($global);
- language_check();
- ############################### PRIORITY SETTINGS ###############################
- if ($_REQUEST['do'] == "settings") {
- admin_header('Priorities', 'Priority Settings');
- include('./settings_include.php');
- show_settings('priority.php', 'Priority Settings');
- }
- ############################### UPDATE PRIORITY SETTINGS ###############################
- if ($_REQUEST['do'] == "update") {
- include('./settings_include.php');
- update_settings();
- jump("priority.php?do=settings", 'Settings updated');
- }
- ############################### ORDER PRIORITY ###############################
- if ($_REQUEST['do'] == "pri_orders") {
- while (list ($key, $val) = each ($_REQUEST['order'])) {
- $key = mysql_escape_string($key);
- $val = mysql_escape_string($val);
- $db->query("UPDATE ticket_pri SET pri_order = '$val' WHERE id = '$key'");
- }
-
- jump("priority.php?do=view", 'Orders updated');
- }
- ############################### DELETE PRIORITY ###############################
- if ($_REQUEST['do'] == "delete") {
- admin_header('Priorities', 'Delete Priority');
- $db->query("SELECT * from ticket_pri WHERE id != '$id'");
- while ($pri = $db->row_array()) {
- $priority[$pri[id]] = $pri[name];
- }
-
- $db->query("SELECT * from ticket_pri WHERE id = '$id'");
- $result = $db->row_array();
- $name = $result[name];
- $bit = form_select('priority', $priority);
- $table = array('<b>Choose a new priority</b><br />You must select a priority to move the tickets with their current priority set as "' . $name . '"', $bit);
- table_header("Delete priority $name", 'priority.php', array('do' => 'delete2', 'id' => $id));
- table_content('', $table);
- table_footer('Delete priority');
- }
- ############################### DELETE (2) PRIORITY ###############################
- if ($_REQUEST['do'] == "delete2") { // update tickets to new priority and add entry into the ticketlog
- $db->query("SELECT id FROM ticket WHERE priority = " . intval($id) . "");
- while ($result = $db->row_array()) {
- $ticket_log[] = array($result[id], 'priority', intval($id), $_REQUEST[priority]);
- }
- ticketlog_array($ticket_log);
- $db->query("UPDATE ticket SET priority = '" . mysql_escape_string($_REQUEST['priority'])."' WHERE priority = " . intval($id));
- $db->query("DELETE from ticket_pri WHERE id='$id'");
- // delete langauage bits
- $priority_languages = unserialize(get_data('priority_languages'));
- if (is_array($priority_languages)) {
- foreach ($priority_languages AS $key => $var) {
- unset($priority_languages[$key][$id]);
- }
- }
- update_data('priority_languages', serialize($priority_languages));
-
- jump('priority.php?do=view', 'Priority deleted');
- }
- ############################### EDIT PRIORITY ###############################
- if (($_REQUEST['do'] == "edit") OR ($_REQUEST['do'] == "add")) {
- if ($_REQUEST['do'] == 'add') {
- admin_header('Priorities', 'Add Priority');
- // lets give some sensible defaults
- $priority[user_view] = 1;
- $priority[user_select] = 1;
- } else {
- admin_header('Priorities', 'Edit Priority');
- }
-
- $db->query("SELECT * from ticket_pri WHERE id != '$id' AND user_view = 1");
- while ($pri = $db->row_array()) {
- $priority2[$pri[id]] = $pri[name];
- }
- if ($_REQUEST['do'] == "edit") {
- $db->query("SELECT * from ticket_pri WHERE id = '$id'");
- $priority = $db->row_array();
- }
- $db->query("SELECT id, username FROM tech ORDER BY username");
- $techs[0] = 'Leave Unassigned';
- while ($tech = $db->row_array()) {
- $techs[$tech[id]] = $tech[username];
- }
- $bit = form_input('priority', $priority[name]);
- $table[] = array('<b>Priority name</b><br />The name for your priority', $bit);
- $bit = form_input('pri_order', $priority[pri_order], 5);
- $table[] = array('<b>Priority order</b><br />The display order of your priority (1 = high)', $bit);
- // there need to be other priorities to enable this
- if (is_array($priority2)) {
- $bit = form_radio_yn('user_view', '', $priority[user_view]);
- $table[] = array('<b>User viewable</b><br />Can the user view the priority? If not, you must select a priority to be displayed to the user instead', $bit);
- $bit = form_select('show_priority', $priority2, '', $priority[show_priority]);
- $table[] = array('<b>User display priority</b><br />If you are hiding the real priority choice from the user you should select a priority to display to the user instead', $bit);
- } else {
- $extra = form_hidden('user_view', 1);
- }
-
- $bit = form_radio_yn('user_select', '', $priority[user_select]);
- $table[] = array('<b>User selectable</b><br />Can the user select this priority when creating or editing tickets? This is different from user viewable because you may wish to have a priority that only techs can assign to tickets but when they do assign that priority to a ticket, the user can see this assignment.', $bit);
- $bit = form_radio_yn('require_registration', '', $priority[require_registration]);
- $table[] = array('<b>Require registration</b><br />Will this priority only accept tickets from registered users?', $bit . $extra);
- unset($extra);
- $bit = form_select('auto_assign_tech', $techs, '', $priority[auto_assign_tech]);
- $table[] = array('<b>Assign to tech</b><br />If you select a tech here, new tickets in this priority will automatically be assigned to that tecb', $bit);
- // languages for priorities
- if ($settings['language_on']) {
- $priority_languages = unserialize(get_data('priority_languages'));
- $table[] = table_midheader('Language Options');
-
- $name = "<table cellpadding="2" cellspacing="0">";
- $db->query(" SELECT * FROM languages
- WHERE id != '$settings[default_language]'
- ");
- while ($lang = $db->row_array()) {
- $name .= "<tr><td><b>$lang[name]</b>:</td><td>" . form_input($lang[id], $priority_languages[$lang[id]][$id]['name'], 30, 'language_name') . "</td></tr>";
- }
- $name .= "</table>";
- $table[] = array('<b>Priority name</b><br />The name for the priority in other languages.', $name);
- }
- $width = array('60%', '40%');
- if ($_REQUEST['do'] == "edit") {
- table_header('Edit Priority ' . $priority[name],'priority.php', array('do' => 'edit2', 'id' => $id));
- table_content('', $table, '', '', '', '', $width);
- table_footer('Edit Priority');
- } else {
- table_header('Create Priority', 'priority.php', array('do' => 'add2'));
- table_content('', $table, '', '', '', '', $width);
- table_footer('Create Priority');
- }
- }
- ############################### EDIT (2) PRIORITY ###############################
- if ($_REQUEST['do'] == "edit2") {
- $db->query("UPDATE ticket_pri SET
- name = '".mysql_escape_string($_REQUEST[priority])."',
- show_priority = " . intval($_REQUEST[show_priority]) . ",
- pri_order = '$_REQUEST[pri_order]',
- user_view = '$_REQUEST[user_view]',
- user_select = '$_REQUEST[user_select]',
- require_registration = '$_REQUEST[require_registration]',
- auto_assign_tech = '$_REQUEST[auto_assign_tech]'
- WHERE id = '$id'
- ");
- // language options for priority
- if ($settings['language_on']) {
- $priority_languages = unserialize(get_data('priority_languages'));
- if (is_array($_REQUEST['language_name'])) {
- foreach ($_REQUEST['language_name'] AS $key => $var) {
- $priority_languages[$key][$id] = array('name' => $var);
- }
- }
- update_data('priority_languages', serialize($priority_languages));
- }
- jump('priority.php?do=view', 'Priority updated');
- }
- ############################### ADD (2) PRIORITY ###############################
- if ($_REQUEST['do'] == "add2") {
- $db->query("INSERT into ticket_pri SET
- name = '" . mysql_escape_string($_REQUEST['priority']) . "',
- show_priority = " . intval($_REQUEST['show_priority']) . ",
- pri_order = '$_REQUEST[pri_order]',
- user_view = '$_REQUEST[user_view]',
- user_select = '$_REQUEST[user_select]',
- require_registration = '$_REQUEST[require_registration]',
- auto_assign_tech = '$_REQUEST[auto_assign_tech]'
- ");
- // language options fo priority
- if ($settings['language_on']) {
- $priority_languages = unserialize(get_data('priority_languages'));
- if (is_array($_REQUEST['language_name'])) {
- foreach ($_REQUEST['language_name'] AS $key => $var) {
- $priority_languages[$key][$id] = array('name' => $var);
- }
- }
- update_data('priority_languages', serialize($priority_languages));
- }
- jump('priority.php?do=view', 'New priority created');
- }
- ############################### VIEW PRIORITY ###############################
- if ($_REQUEST['do'] == "view") {
- admin_header('Priorities', 'View Priorities');
- $db->query("SELECT id, username FROM tech ORDER BY username");
- $techs[0] = 'Leave Unassigned';
- while ($tech = $db->row_array()) {
- $techs[$tech['id']] = $tech['username'];
- }
-
- $db->query("SELECT * from ticket_pri ORDER by pri_order");
- while ($priority = $db->row_array()) {
- $table[] = array(
- form_input($priority[id], $priority[pri_order], '4', 'order'),
- "<B>$priority[name]</b>",
- ifynb($priority['user_view']),
- ifynb($priority['user_select']),
- ifynb($priority['require_registration']),
- $techs[$priority['auto_assign_tech']],
- "<a href="priority.php?do=delete&id=$priority[id]">delete</a>",
- "<a href="priority.php?do=edit&id=$priority[id]">edit</a>"
- );
- }
- $cols = array('Order', 'Name', 'User Viewable', 'User Selectable', 'Registration Required', 'Assign to Technician', 'Delete', 'Edit');
- table_header('Priorities', 'priority.php', array('do' => 'pri_orders'));
- table_content($cols, $table);
- table_footer('Update Priority Orders');
- unset($table);
-
- echo "<P><center><font face="verdana, arial, helvetica" size="2"><a href="priority.php?do=add">Add New Priority</a></font></center>";
- }
- ##############################################################
- admin_footer();
- ?>