/**
 * Obtain a value of a field for a given row from the database table.
 */
function id2field($table, $field, $idf, $id, $toupper = True)
{
    $db = $GLOBALS['phpgw']->db;
    $sql = 'SELECT ' . $db->db_addslashes($field) . ' FROM ' . $db->db_addslashes($table) . " WHERE " . $db->db_addslashes($idf) . "=" . intval($id);
    $db->query($sql, __FILE__, __LINE__);
    if ($db->next_record()) {
        return try_lang($db->f($field, True), False, $toupper);
    } else {
        return '';
    }
}
$GLOBALS['phpgw']->template->set_var('tts_head_transition_id', $GLOBALS['phpgw']->nextmatchs->show_sort_order($sort, 'transition_id', $order, '/tts/transitions.php', '#'));
$GLOBALS['phpgw']->template->set_var('tts_head_transition', $GLOBALS['phpgw']->nextmatchs->show_sort_order($sort, 'transition_name', $order, '/tts/transitions.php', lang('Transition')));
$GLOBALS['phpgw']->template->set_var('tts_head_description', $GLOBALS['phpgw']->nextmatchs->show_sort_order($sort, 'transition_description', $order, '/tts/transitions.php', lang('Description')));
$GLOBALS['phpgw']->template->set_var('tts_head_target_state', $GLOBALS['phpgw']->nextmatchs->show_sort_order($sort, 'transition_target_state', $order, '/tts/transitions.php', lang('Target State')));
$GLOBALS['phpgw']->template->set_var('tts_head_source_state', $GLOBALS['phpgw']->nextmatchs->show_sort_order($sort, 'transition_source_state', $order, '/tts/transitions.php', lang('Source State')));
$GLOBALS['phpgw']->template->set_var('lang_add', lang('Add'));
$GLOBALS['phpgw']->template->set_var('lang_edit', lang('Edit'));
$GLOBALS['phpgw']->template->set_var('lang_delete', lang('Delete'));
if ($db2->num_rows() == 0) {
    $GLOBALS['phpgw']->template->set_var('rows', '<p><center>' . lang('No transitions found') . '</center>');
} else {
    $i = 0;
    while ($db2->next_record()) {
        $GLOBALS['phpgw']->template->set_var('tts_col_status', '');
        $GLOBALS['phpgw']->template->set_var('row_class', ++$i & 1 ? 'row_on' : 'row_off');
        $GLOBALS['phpgw']->template->set_var('tts_transitionedit_link', $GLOBALS['phpgw']->link('/tts/edit_transition.php', 'transition_id=' . $db2->f('transition_id')));
        $GLOBALS['phpgw']->template->set_var('tts_transitiondelete_link', $GLOBALS['phpgw']->link('/tts/delete_transition.php', 'transition_id=' . $db2->f('transition_id')));
        $GLOBALS['phpgw']->template->set_var('transition_id', $db2->f('transition_id'));
        $GLOBALS['phpgw']->template->set_var('transition_name', try_lang($name = $db2->f('transition_name'), False, True));
        $GLOBALS['phpgw']->template->set_var('transition_description', try_lang($db2->f('transition_description'), try_lang(substr($name, 2))));
        $GLOBALS['phpgw']->template->set_var('transition_source_state', id2field('phpgw_tts_states', 'state_name', 'state_id', $db2->f('transition_source_state')));
        $GLOBALS['phpgw']->template->set_var('transition_target_state', id2field('phpgw_tts_states', 'state_name', 'state_id', $db2->f('transition_target_state')));
        $GLOBALS['phpgw']->template->parse('rows', 'transition_row', True);
    }
}
$GLOBALS['phpgw']->template->set_var('row_class', ++$i & 1 ? 'row_on' : 'row_off');
$GLOBALS['phpgw']->template->set_var('tts_transitionadd_link', $GLOBALS['phpgw']->link('/tts/edit_transition.php', 'transition_id=0'));
// this is a workaround to clear the subblocks autogenerated vars
$GLOBALS['phpgw']->template->set_var('transition_row', '');
$GLOBALS['phpgw']->template->pfp('out', 'transitions');
$GLOBALS['phpgw']->common->phpgw_footer();
$GLOBALS['phpgw']->template->set_var('lang_tickets_in_state', lang('The tickets in the following list are in the state %1. Please, decide what should be done with them.', $s));
$GLOBALS['phpgw']->template->set_var('lang_preferences', lang('Preferences'));
$GLOBALS['phpgw']->template->set_var('lang_search', lang('search'));
$GLOBALS['phpgw']->template->set_var('tts_newticket', lang('New ticket'));
$GLOBALS['phpgw']->template->set_var('tts_head_status', lang('Status'));
$GLOBALS['phpgw']->template->set_var('tts_notickets', '');
$GLOBALS['phpgw']->template->set_var('lang_category', lang('Category'));
$GLOBALS['phpgw']->template->set_var('delete_state_link', $GLOBALS['phpgw']->link('/tts/delete_state.php', 'state_id=' . $state_id));
$GLOBALS['phpgw']->template->set_var('lang_delete_the_tickets', lang('Delete the listed tickets.'));
$GLOBALS['phpgw']->template->set_var('lang_irregular_move_into_state', lang('Perform irregular transition into the following state'));
$GLOBALS['phpgw']->template->set_var('lang_delete', lang('Delete'));
$GLOBALS['phpgw']->template->set_var('lang_cancel', lang('Cancel'));
$GLOBALS['phpgw']->db->query("select * from phpgw_tts_transitions where transition_source_state=" . $state_id, __LINE__, __FILE__);
while ($GLOBALS['phpgw']->db->next_record()) {
    $GLOBALS['phpgw']->template->set_var('update_state_value', try_lang($GLOBALS['phpgw']->db->f('transition_target_state')));
    $GLOBALS['phpgw']->template->set_var('update_state_text', try_lang($GLOBALS['phpgw']->db->f('transition_description')));
    $GLOBALS['phpgw']->template->parse('update_state_group', 'update_state_items', True);
}
// Choose the initial state to display
$GLOBALS['phpgw']->template->set_var('options_state', listid_field('phpgw_tts_states', 'state_name', 'state_id', '', "state_id<>" . $state_id));
if (!$sort) {
    $sortmethod = 'order by ticket_priority desc';
} else {
    $sortmethod = "order by {$order} {$sort}";
}
$GLOBALS['phpgw']->db->query("select count(*) from phpgw_tts_tickets where ticket_state=" . $state_id, __LINE__, __FILE__);
$GLOBALS['phpgw']->db->next_record();
$numtotal = $GLOBALS['phpgw']->db->f('0');
$GLOBALS['phpgw']->db->query("select count(*) from phpgw_tts_tickets where ticket_status='O' and ticket_state=" . $state_id, __LINE__, __FILE__);
$GLOBALS['phpgw']->db->next_record();
$numopen = $GLOBALS['phpgw']->db->f('0');
Exemplo n.º 4
0
}
$GLOBALS['phpgw']->db->query("select * from phpgw_tts_states {$filtermethod} {$sortmethod}", __LINE__, __FILE__);
$numfound = $GLOBALS['phpgw']->db->num_rows();
// fill header
$GLOBALS['phpgw']->template->set_var('tts_head_stateid', $GLOBALS['phpgw']->nextmatchs->show_sort_order($sort, 'state_id', $order, '/tts/states.php', '#'));
$GLOBALS['phpgw']->template->set_var('tts_head_state', $GLOBALS['phpgw']->nextmatchs->show_sort_order($sort, 'state_name', $order, '/tts/states.php', lang('State')));
$GLOBALS['phpgw']->template->set_var('tts_head_description', $GLOBALS['phpgw']->nextmatchs->show_sort_order($sort, 'state_description', $order, '/tts/states.php', lang('Description')));
$GLOBALS['phpgw']->template->set_var('lang_add', lang('Add'));
$GLOBALS['phpgw']->template->set_var('lang_edit', lang('Edit'));
$GLOBALS['phpgw']->template->set_var('lang_delete', lang('Delete'));
if ($GLOBALS['phpgw']->db->num_rows() == 0) {
    $GLOBALS['phpgw']->template->set_var('rows', '<p><center>' . lang('No states found') . '</center>');
} else {
    $i = 0;
    while ($GLOBALS['phpgw']->db->next_record()) {
        $GLOBALS['phpgw']->template->set_var('tts_col_status', '');
        $GLOBALS['phpgw']->template->set_var('row_class', ++$i & 1 ? 'row_on' : 'row_off');
        $GLOBALS['phpgw']->template->set_var('tts_stateedit_link', $GLOBALS['phpgw']->link('/tts/edit_state.php', 'state_id=' . $GLOBALS['phpgw']->db->f('state_id')));
        $GLOBALS['phpgw']->template->set_var('tts_statedelete_link', $GLOBALS['phpgw']->link('/tts/delete_state.php', 'state_id=' . $GLOBALS['phpgw']->db->f('state_id')));
        $GLOBALS['phpgw']->template->set_var('state_id', $GLOBALS['phpgw']->db->f('state_id'));
        $GLOBALS['phpgw']->template->set_var('state_name', try_lang($GLOBALS['phpgw']->db->f('state_name'), False, True));
        $GLOBALS['phpgw']->template->set_var('state_description', try_lang($GLOBALS['phpgw']->db->f('state_description'), False));
        $GLOBALS['phpgw']->template->parse('rows', 'state_row', True);
    }
}
$GLOBALS['phpgw']->template->set_var('row_class', ++$i & 1 ? 'row_on' : 'row_off');
$GLOBALS['phpgw']->template->set_var('tts_stateadd_link', $GLOBALS['phpgw']->link('/tts/edit_state.php', 'state_id=0'));
// this is a workaround to clear the subblocks autogenerated vars
$GLOBALS['phpgw']->template->set_var('state_row', '');
$GLOBALS['phpgw']->template->pfp('out', 'states');
$GLOBALS['phpgw']->common->phpgw_footer();
    $GLOBALS['phpgw']->template->set_var('value_details', nl2br($ticket['details']));
    $GLOBALS['phpgw']->template->set_var('value_subject', $ticket['subject']);
    $GLOBALS['phpgw']->template->set_var('lang_additional_notes', lang('Additional notes'));
    $GLOBALS['phpgw']->template->set_var('lang_save', lang('Save'));
    $GLOBALS['phpgw']->template->set_var('lang_apply', lang('Apply'));
    $GLOBALS['phpgw']->template->set_var('lang_cancel', lang('Cancel'));
    $GLOBALS['phpgw']->template->set_var('lang_category', lang('Category'));
    $GLOBALS['phpgw']->template->set_var('value_category', $GLOBALS['phpgw']->categories->id2name($ticket['category']));
    $GLOBALS['phpgw']->template->set_var('options_select', '');
    $GLOBALS['phpgw']->template->set_var('lang_update_state', lang('Update ticket state'));
    $GLOBALS['phpgw']->template->set_var('lang_keep_present_state', lang('Keep the present state [%1].', id2field('phpgw_tts_states', 'state_name', 'state_id', $ticket['state'])));
    $db = clone $GLOBALS['phpgw']->db;
    $db->query("select * from phpgw_tts_transitions where transition_source_state=" . $ticket['state'], __LINE__, __FILE__);
    while ($db->next_record()) {
        $GLOBALS['phpgw']->template->set_var('update_state_value', $db->f('transition_target_state'));
        $GLOBALS['phpgw']->template->set_var('update_state_text', try_lang($db->f('transition_description'), id2field('phpgw_tts_states', 'state_name', 'state_id', $db->f('transition_target_state'))));
        $GLOBALS['phpgw']->template->parse('update_state_group', 'update_state_items', True);
    }
    $GLOBALS['phpgw']->template->pfp('out', 'form');
    $GLOBALS['phpgw']->common->phpgw_footer();
} else {
    $ticket = $_POST['ticket'];
    // DB Content is fresher than http posted value.
    $GLOBALS['phpgw']->db->query("select * from phpgw_tts_tickets where ticket_id='{$ticket_id}'", __LINE__, __FILE__);
    $GLOBALS['phpgw']->db->next_record();
    $oldassigned = $GLOBALS['phpgw']->db->f('ticket_assignedto');
    $oldpriority = $GLOBALS['phpgw']->db->f('ticket_priority');
    $oldcategory = $GLOBALS['phpgw']->db->f('ticket_category');
    $old_status = $GLOBALS['phpgw']->db->f('ticket_status');
    $old_billable_hours = $GLOBALS['phpgw']->db->f('ticket_billable_hours');
    $old_billable_rate = $GLOBALS['phpgw']->db->f('ticket_billable_rate');
    if (!$transition_id) {
        $GLOBALS['phpgw']->db->query("insert into phpgw_tts_transitions (transition_name,transition_description,transition_source_state,transition_target_state) values ('" . addslashes($transition['name']) . "','" . addslashes($transition['description']) . "'," . intval($transition['source_state']) . ", " . intval($transition['target_state']) . ")", __LINE__, __FILE__);
    } else {
        $GLOBALS['phpgw']->db->query("update phpgw_tts_transitions " . " set transition_name='" . addslashes($transition['name']) . "', " . " transition_description='" . addslashes($transition['description']) . "', " . " transition_source_state=" . intval($transition['source_state']) . ", " . " transition_target_state=" . intval($transition['target_state']) . " WHERE transition_id=" . $transition_id, __LINE__, __FILE__);
    }
    $GLOBALS['phpgw']->redirect_link('/tts/transitions.php');
} else {
    $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['tts']['title'] . ' - ' . ($transition_id ? lang('Create new transition') : lang('Edit the transition'));
    $GLOBALS['phpgw']->common->phpgw_header();
    // select the ticket that you selected
    $GLOBALS['phpgw']->db->query("select * from phpgw_tts_transitions where transition_id='{$transition_id}'", __LINE__, __FILE__);
    $GLOBALS['phpgw']->db->next_record();
    $transition['name'] = try_lang($GLOBALS['phpgw']->db->f('transition_name'));
    $transition['source_state'] = try_lang($GLOBALS['phpgw']->db->f('transition_source_state'));
    $transition['target_state'] = try_lang($GLOBALS['phpgw']->db->f('transition_target_state'));
    $transition['description'] = try_lang($GLOBALS['phpgw']->db->f('transition_description'), $transition['target_state']);
    $GLOBALS['phpgw']->template->set_file(array('edit_transition' => 'edit_transition.tpl'));
    $GLOBALS['phpgw']->template->set_block('edit_transition', 'form');
    $GLOBALS['phpgw']->template->set_var('form_action', $GLOBALS['phpgw']->link('/tts/edit_transition.php', '&transition_id=' . $transition_id));
    $GLOBALS['phpgw']->template->set_var('lang_transition_name', lang('Transition name'));
    $GLOBALS['phpgw']->template->set_var('lang_transition_description', lang('Description'));
    $GLOBALS['phpgw']->template->set_var('lang_source_state', lang('Source State'));
    $GLOBALS['phpgw']->template->set_var('lang_target_state', lang('Target State'));
    $GLOBALS['phpgw']->template->set_var('lang_save', lang('Save'));
    $GLOBALS['phpgw']->template->set_var('lang_cancel', lang('Cancel'));
    $GLOBALS['phpgw']->template->set_var('value_name', $transition['name']);
    $GLOBALS['phpgw']->template->set_var('value_description', $transition['description']);
    $GLOBALS['phpgw']->template->set_var('options_source_state', listid_field('phpgw_tts_states', 'state_name', 'state_id', $transition['source_state']));
    $GLOBALS['phpgw']->template->set_var('options_target_state', listid_field('phpgw_tts_states', 'state_name', 'state_id', $transition['target_state']));
    $GLOBALS['phpgw']->template->pfp('out', 'form');
    $GLOBALS['phpgw']->common->phpgw_footer();
    $GLOBALS['phpgw']->db->next_record();
    $state['name'] = $GLOBALS['phpgw']->db->f('state_name');
    $state['description'] = try_lang($GLOBALS['phpgw']->db->f('state_description'));
    $state['initial'] = $GLOBALS['phpgw']->db->f('state_initial');
    $GLOBALS['phpgw']->template->set_file(array('edit_state' => 'edit_state.tpl'));
    $GLOBALS['phpgw']->template->set_block('edit_state', 'form');
    $GLOBALS['phpgw_info']['flags']['app_header'] = $GLOBALS['phpgw_info']['apps']['tts']['title'] . ' - ' . (!$state_id ? lang('Create new state') : lang('Edit the state'));
    $GLOBALS['phpgw']->common->phpgw_header();
    $GLOBALS['phpgw']->template->set_var('form_action', $GLOBALS['phpgw']->link('/tts/edit_state.php', array(state_id => $state_id)));
    if (!$state_id) {
        $GLOBALS['phpgw']->template->set_block('form', 'autoid', 'aid');
        $GLOBALS['phpgw']->template->set_var('lang_auto_id', lang("Check here to generate the state's ID automatically or enter a particular ID below."));
        $GLOBALS['phpgw']->template->parse('aid', 'autoid', True);
    } else {
        $GLOBALS['phpgw']->template->set_block('form', 'autoid', 'aid');
        $GLOBALS['phpgw']->template->set_var('aid', '');
        //clear the section
    }
    $GLOBALS['phpgw']->template->set_var('lang_state_id', lang('State ID'));
    $GLOBALS['phpgw']->template->set_var('lang_state_name', lang('State Name'));
    $GLOBALS['phpgw']->template->set_var('lang_state_description', lang('Description'));
    $GLOBALS['phpgw']->template->set_var('lang_new_ticket_into_state', lang('New tickets can be put into this state.'));
    $GLOBALS['phpgw']->template->set_var('lang_save', lang('Save'));
    $GLOBALS['phpgw']->template->set_var('lang_cancel', lang('Cancel'));
    $GLOBALS['phpgw']->template->set_var('value_description', $state['description']);
    $GLOBALS['phpgw']->template->set_var('value_id', $state_id > 0 ? intval($state_id) : '');
    $GLOBALS['phpgw']->template->set_var('value_name', try_lang($state['name']));
    $GLOBALS['phpgw']->template->set_var('value_initial', $state['initial'] ? 'CHECKED' : '');
    $GLOBALS['phpgw']->template->pfp('out', 'form');
    $GLOBALS['phpgw']->common->phpgw_footer();
}