<?php
/*
  www.oscGold.com (C) Kamelia-Net Jacek Krysiak
  modul oscGold wer 4.0
*/

  function tep_get_ticket_admin_name($ticket_admin_id, $language_id = '') {
    global $languages_id;

    if ($ticket_admin_id < 1) return TEXT_DEFAULT;

    if (!is_numeric($language_id)) $language_id = $languages_id;

    $status_query = tep_db_query("select ticket_admin_name from " . TABLE_TICKET_ADMIN . " where ticket_admin_id = '" . $ticket_admin_id . "' and ticket_language_id = '" . $language_id . "'");
    $admin = tep_db_fetch_array($status_query);

    return $admin['ticket_admin_name'];
  }

  function tep_get_ticket_department_name($ticket_department_id, $language_id = '') {
    global $languages_id;

    if ($ticket_department_id < 1) return TEXT_DEFAULT;

    if (!is_numeric($language_id)) $language_id = $languages_id;

    $status_query = tep_db_query("select ticket_department_name from " . TABLE_TICKET_DEPARTMENT . " where ticket_department_id = '" . $ticket_department_id . "' and ticket_language_id = '" . $language_id . "'");
    $department = tep_db_fetch_array($status_query);

    return $department['ticket_department_name'];
  }

function tep_get_ticket_priority_name($ticket_priority_id) {
    global $languages_id;

    if ($ticket_priority_id < 1) return TEXT_DEFAULT;

    $status_query = tep_db_query("select ticket_priority_name from " . TABLE_TICKET_PRIORITY . " where ticket_priority_id = '" . $ticket_priority_id . "'");
    $priority = tep_db_fetch_array($status_query);

    return $priority['ticket_priority_name'];
  }
  function tep_get_ticket_reply_name($ticket_reply_id) {

    if ($ticket_reply_id < 1) return TEXT_DEFAULT;

    $status_query = tep_db_query("select ticket_reply_name from " . TABLE_TICKET_REPLY . " where ticket_reply_id = '" . $ticket_reply_id . "'");
    $reply = tep_db_fetch_array($status_query);

    return $reply['ticket_reply_name'];
  }

  function tep_get_ticket_reply_text($ticket_reply_id) {

    if ($ticket_reply_id < 1) return TEXT_DEFAULT;

    $status_query = tep_db_query("select ticket_reply_text from " . TABLE_TICKET_REPLY . " where ticket_reply_id = '" . $ticket_reply_id . "'");
    $reply = tep_db_fetch_array($status_query);

    return $reply['ticket_reply_text'];
  }

  function tep_cfg_pull_down_admin_reply($ticket_admin_id, $key = '') {

    $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

    $admins_array = array();
    $admins_query = tep_db_query("select admin_id, admin_firstname, admin_lastname from admin order by admin_lastname");
    while ($admins = tep_db_fetch_array($admins_query)) {
      $admins_array[] = array('id' => $admins['admin_id'],
                                'text' => $admins['admin_firstname'] . ' ' . $admins['admin_lastname']);
    }

    return tep_draw_pull_down_menu($name, $admins_array, $ticket_admin_id);
  }

  function tep_get_admin_reply_name($ticket_admin_id) {

    if ($ticket_admin_id < 1) return TEXT_DEFAULT;

    $admins_query = tep_db_query("select admin_firstname, admin_lastname from admin where admin_id = '" . (int)$ticket_admin_id . "'");
    $admins = tep_db_fetch_array($admins_query);

    $ticket_admin = $admins['admin_firstname'] . ' ' . $admins['admin_lastname'];

    return $ticket_admin;
  }

  function tep_cfg_pull_down_departments($ticket_departments_id, $key = '') {

    $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

    $departments_array = array();
    $departments_query = tep_db_query("select admin_groups_id, admin_groups_name from admin_groups order by admin_groups_name");
    while ($departments = tep_db_fetch_array($departments_query)) {
      $departments_array[] = array('id' => $departments['admin_groups_id'],
                                'text' => $departments['admin_groups_name']);
    }

    return tep_draw_pull_down_menu($name, $departments_array, $ticket_departments_id);
  }

  function tep_get_departments_name($ticket_departments_id) {

    if ($ticket_departments_id < 1) return TEXT_DEFAULT;

    $departments_query = tep_db_query("select admin_groups_id, admin_groups_name from admin_groups where admin_groups_id = '" . (int)$ticket_departments_id . "'");
    $departments = tep_db_fetch_array($departments_query);

    return $departments['admin_groups_name'];
  }

  function tep_cfg_pull_down_priority($ticket_priority_id, $key = '') {

    $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

    $priority_array = array();
    $priority_query = tep_db_query("select ticket_priority_id, ticket_priority_name from ticket_priority order by ticket_priority_name");
    while ($priority = tep_db_fetch_array($priority_query)) {
      $priority_array[] = array('id' => $priority['ticket_priority_id'],
                                'text' => $priority['ticket_priority_name']);
    }

    return tep_draw_pull_down_menu($name, $priority_array, $ticket_priority_id);
  }

  function tep_get_priority_name($ticket_priority_id) {

    if ($ticket_priority_id < 1) return TEXT_DEFAULT;

    $priority_query = tep_db_query("select ticket_priority_id, ticket_priority_name from ticket_priority where ticket_priority_id = '" . (int)$ticket_priority_id . "'");
    $priority = tep_db_fetch_array($priority_query);

    return $priority['ticket_priority_name'];
  }


  function tep_cfg_pull_down_reply($ticket_reply_id, $key = '') {

    $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

    $reply_array = array();
    $reply_query = tep_db_query("select ticket_reply_id, ticket_reply_name from ticket_reply order by ticket_reply_name");
    while ($reply = tep_db_fetch_array($reply_query)) {
      $reply_array[] = array('id' => $reply['ticket_reply_id'],
                             'text' => $reply['ticket_reply_name']);
    }

    return tep_draw_pull_down_menu($name, $reply_array, $ticket_priority_id);
  }

  function tep_get_reply_name($ticket_reply_id) {

    if ($ticket_reply_id < 1) return TEXT_DEFAULT;

    $reply_query = tep_db_query("select ticket_reply_id, ticket_reply_name from ticket_reply where ticket_reply_id = '" . (int)$ticket_reply_id . "'");
    $reply = tep_db_fetch_array($reply_query);

    return $reply['ticket_reply_name'];
  }


  function tep_cfg_pull_down_status($ticket_reply_id, $key = '') {

    $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

    $status_array = array();
    $status_query = tep_db_query("select ticket_status_id, ticket_status_name from ticket_status order by ticket_status_name");
    while ($status = tep_db_fetch_array($status_query)) {
      $status_array[] = array('id' => $status['ticket_status_id'],
                             'text' => $status['ticket_status_name']);
    }

    return tep_draw_pull_down_menu($name, $status_array, $ticket_status_id);
  }

  function tep_get_ticket_status_name($ticket_status_id) {

    if ($ticket_status_id < 1) return TEXT_DEFAULT;

    $status_query = tep_db_query("select ticket_status_name from " . TABLE_TICKET_STATUS . " where ticket_status_id = '" . $ticket_status_id . "'");
    $status = tep_db_fetch_array($status_query);

    return $status['ticket_status_name'];
  }


?>