';
//Add the default value as a first option
if($defaultval != '')
$list .= '';
foreach($value as $index => $val)
{
$selected = '';
if($selectval == $val)
$selected = ' selected ';
$list .= '';
}
$list .= '';
return $list;
}
function UpdateComment()
{
global $client;
$ticketid = $_REQUEST['ticketid'];
$ownerid = $_SESSION['customer_id'];
$comments = $_REQUEST['comments'];
$customerid = $_SESSION['customer_id'];
$sessionid = $_SESSION['customer_sessionid'];
$params = Array(Array('id'=>"$customerid", 'sessionid'=>"$sessionid", 'ticketid'=>"$ticketid",'ownerid'=>"$customerid",'comments'=>"$comments"));
$commentresult = $client->call('update_ticket_comment', $params, $Server_Path, $Server_Path);
}
function Close_Ticket($ticketid)
{
global $client;
$customerid = $_SESSION['customer_id'];
$sessionid = $_SESSION['customer_sessionid'];
$params = Array(Array('id'=>"$customerid", 'sessionid'=>"$sessionid", 'ticketid'=>"$ticketid"));
$result = $client->call('close_current_ticket', $params, $Server_Path, $Server_Path);
return $result;
}
function getPicklist($picklist_name)
{
global $client;
$customerid = $_SESSION['customer_id'];
$sessionid = $_SESSION['customer_sessionid'];
$params = Array(Array('id'=>"$customerid", 'sessionid'=>"$sessionid", 'picklist_name'=>"$picklist_name"));
$temp_picklist_array = $client->call('get_picklists', $params, $Server_Path, $Server_Path);
$ticket_picklist_array=array();
foreach ($temp_picklist_array as $value) $ticket_picklist_array[$value]=getTranslatedString($value);
return $ticket_picklist_array;
}
function getStatusComboList($selectedvalue='')
{
global $mod_strings;
$temp_array = getPicklist('ticketstatus');
$status_combo = "";
foreach($temp_array as $index => $val)
{
$select = '';
if($val == $selectedvalue)
$select = ' selected';
$status_combo .= '';
}
return $status_combo;
}
//Added for My Settings - Save Password
function SavePassword()
{
global $client;
global $mod_strings;
$customer_id = $_SESSION['customer_id'];
$customer_name = $_SESSION['customer_name'];
$oldpw = trim($_REQUEST['old_password']);
$newpw = $_REQUEST['new_password'];
$confirmpw = $_REQUEST['confirm_password'];
$params = Array('user_name'=>"$customer_name",'user_password'=>"$oldpw",'login'=>"false");
$result = $client->call('authenticate_user',$params);
$sessionid = $_SESSION['customer_sessionid'];
if($oldpw == $result[0]['user_password'])
{
if($newpw == $confirmpw)
{
$customerid = $result[0]['id'];
// $customerid = $_SESSION['customer_id'];
$sessionid = $_SESSION['customer_sessionid'];
$params = Array(Array('id'=>"$customerid", 'sessionid'=>"$sessionid", 'username'=>"$customer_name",'password'=>"$newpw"));
$result = $client->call('change_password',$params);
$errormsg .= $mod_strings['MSG_PASSWORD_CHANGED'];
}
else
{
$errormsg = $mod_strings['MSG_ENTER_NEW_PASSWORDS_SAME'];
}
}
else
{
$errormsg = $mod_strings['MSG_YOUR_PASSWORD_WRONG'];
}
return $errormsg;
}
function getTicketAttachmentsList($ticketid)
{
global $client;
global $mod_strings;
$customer_name = $_SESSION['customer_name'];
$customerid = $_SESSION['customer_id'];
$sessionid = $_SESSION['customer_sessionid'];
$params = Array(Array('id'=>"$customerid", 'sessionid'=>"$sessionid", 'ticketid'=>"$ticketid"));
$result = $client->call('get_ticket_attachments',$params);
return $result;
}
function AddAttachment()
{
global $client;
$ticketid = $_REQUEST['ticketid'];
$ownerid = $_SESSION['customer_id'];
$filename = $_FILES['customerfile']['name'];
$filetype = $_FILES['customerfile']['type'];
$filesize = $_FILES['customerfile']['size'];
$fileerror = $_FILES['customerfile']['error'];
if (isset($_REQUEST['customerfile_hidden'])) {
$filename = $_REQUEST['customerfile_hidden'];
}
$upload_error = '';
if($fileerror == 4)
{
$upload_error = $mod_strings['MSG_FILE_UPL_ERR_VALID_FILE'];
}
elseif($fileerror == 2)
{
$upload_error = $mod_strings['MSG_FILE_UPL_ERR_MAX_SIZE'];
}
elseif($fileerror == 3)
{
$upload_error = $mod_strings['MSG_FILE_UPL_PROBLEM'];
}
//Copy the file in temp and then read and pass the contents of the file as a string to db
global $upload_dir;
if($filesize > 0)
{
if(move_uploaded_file($_FILES["customerfile"]["tmp_name"],$upload_dir.'/'.$filename))
{
$filecontents = base64_encode(fread(fopen($upload_dir.'/'.$filename, "r"), $filesize));
}
$customerid = $_SESSION['customer_id'];
$sessionid = $_SESSION['customer_sessionid'];
$params = Array(Array(
'id'=>"$customerid",
'sessionid'=>"$sessionid",
'ticketid'=>"$ticketid",
'filename'=>"$filename",
'filetype'=>"$filetype",
'filesize'=>"$filesize",
'filecontents'=>"$filecontents"
));
$commentresult = $client->call('add_ticket_attachment', $params, $Server_Path, $Server_Path);
}
else
{
$upload_error = $mod_strings['MSG_FILE_UPL_ERR_PLS_VALID'];
}
return $upload_error;
}
/** Function used to get the translated string to the input string
* @param string $str - input string which we want to translate
* @return string $str - translated string, if the translated string
* is available then the translated string other wise original string will be returned
*/
function getTranslatedString($str)
{
global $mod_strings;
$temp_mod_strings = $mod_strings;
include('language/en_us.lang.php');
$trans_str = ($temp_mod_strings[$str] != '')?$temp_mod_strings[$str]:(($mod_strings[$str] != '')?$mod_strings[$str]:$str);
$mod_strings = $temp_mod_strings;
return $trans_str;
}
?>