';
}
$template{'response'} = $response;
parse("$global{'data'}/include/tpl/staff/general");
}
if ($section eq "update_list_calls")
{
check_user();
my $status = $q->param('status');
my $action = $q->param('action_call');
if ($action eq "delete")
{
@checkbx = $q->param('ticket_check');
for ( @checkbx )
{
die_nice("The administrator has removed staff deletion access") if $global{'sdelete'} == "0";
$dbh->do(qq|DELETE FROM perlDesk_calls WHERE id = "$_"|);
}
if ($status eq "main") { $surl = "staff.cgi?do=main"; } else { $surl = "staff.cgi?do=listcalls&status=$statys"; }
print "Content-type: text/html\n\n";
print qq|
Ticket List Updated , you are now being taken back to the listings.
click
here if you are not automatically forwarded
|;
}
if ($action eq "own")
{
@checkbx = $q->param('ticket_check');
for ( @checkbx )
{
$dbh->do(qq|UPDATE perlDesk_calls SET ownership = "$Cookies{'staff'}" WHERE id = "$_"|);
my $sdsth = $dbh->prepare( "INSERT INTO perlDesk_activitylog VALUES ( ?, ?, ?, ?, ?)" );
$sdsth->execute( "NULL", $_, $hdtime, "Staff $Cookies{'staff'}", "$Cookies{'staff'} Claimed Ownership" ) or die "Couldn't execute statement: $DBI::errstr; stopped";
}
if ($status eq "main") { $surl = "staff.cgi?do=main"; } else { $surl = "staff.cgi?do=listcalls&status=$statys"; }
print "Content-type: text/html\n\n";
print qq|
Ticket List Updated , you are now being taken back to the listings.
click
here if you are not automatically forwarded
|;
}
if ($action eq "respond")
{
@checkbx = $q->param('ticket_check');
for ( @checkbx )
{ $template{'hidden'} .= qq| \n|; }
print "Content-type: text/html\n\n";
parse("$global{'data'}/include/tpl/staff/mass_respond");
}
}
if ($section eq "refresh_calls")
{
check_user();
print "Content-type: text/html\n\n";
my $status = $q->param('status');
my $comments = $q->param('comments');
$mstatus = "open" if $status eq "OPEN";
$mstatus = "closed" if $status eq "CLOSED";
@checkbx = $q->param('ticket_check');
for ( @checkbx )
{
my @chars = ("A..Z","0..9","a..z");
$key = $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)];
$dbh->do(qq|UPDATE perlDesk_calls SET status = "$status", closedby = "$Cookies{'staff'}" WHERE id = "$_"|) if $status eq "CLOSED";
$dbh->do(qq|UPDATE perlDesk_calls SET status = "$status" WHERE id = "$_"|) if $status ne "CLOSED";
$rv = $dbh->do(qq{INSERT INTO perlDesk_notes values (
"NULL", "1", "1", "$status", "$_", "$staff_id", "$hdtime", "$key", "$comments", "$ENV{'REMOTE_ADDR'}")}
);
}
print qq|
Ticket List Updated , you are now being taken back to the listings.
click
here if you are not automatically forwarded
|;
}
if ($section eq "editnotesave") {
check_user();
print "Content-type: text/html\n\n";
my $comment = $q->param('comment');
my $ticket = $q->param('ticket');
my $note = $q->param('note');
$comment =~ s/\"/\\"/g;
$statement = 'UPDATE perlDesk_notes SET comment = "' . "$comment" . '" WHERE id = "' . "$note" . '";';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
print qq|
Thank You , this ticket has been updated.
click
here if you are not automatically forwarded
|;
}
if ($section eq "logout")
{
check_user();
$statement = 'UPDATE perlDesk_staffactive SET date = "0" WHERE username = "' . "$Cookies{'staff'}" . '";';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
$sth->finish;
$cookie1 = $q->cookie(-name =>'staff',
-value =>'',
-path =>'/',
-domain=>'');
$cookie2 = $q->cookie(-name =>'spass',
-value =>'',
-path =>'/',
-domain=>'');
print $q->header(-cookie=>[$cookie1,$cookie2]);
print qq|
Thanks for logging out
click
here if you are not automatically forwarded
|;
}
if ($section eq "notice")
{
check_user();
print "Content-type: text/html\n\n";
$notic = $q->param('id');
$statement = 'SELECT * FROM perlDesk_announce WHERE staff = "1" AND id = ?';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute($notic) or die print "Couldn't execute statement: $DBI::errstr; stopped";
while(my $ref = $sth->fetchrow_hashref())
{
$notice .= 'Author: ' . "$ref->{'author'}" . '
Published: ' . "$ref->{'time'}" . '
Subject: ' . "$ref->{'subject'}" . ' Announcement: ' . "$ref->{'message'}" . '
';
}
$template{'announcement'} = $notice;
parse("$global{'data'}/include/tpl/staff/announcement");
}
if ($section eq "myperformance")
{
check_user();
print "Content-type: text/html\n\n";
$sth = $dbh->prepare(qq|SELECT COUNT(*) FROM perlDesk_calls WHERE status = "CLOSED" AND closedby = "$Cookies{'staff'}"|) or die DBI->errstr;
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
my $closed = $sth->fetchrow_array();
$sth->finish;
$sth = $dbh->prepare('SELECT COUNT(*) FROM perlDesk_calls WHERE status = "CLOSED"' ) or die DBI->errstr;
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
my $total = $sth->fetchrow_array();
$sth->finish;
$sth = $dbh->prepare('SELECT COUNT(*) FROM perlDesk_calls') or die DBI->errstr;
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
my $count = $sth->fetchrow_array();
$sth->finish;
#~~
# Work Out Rating
#~~
$statement = qq|SELECT SUM(rating) FROM perlDesk_reviews WHERE staff = "$staff_id"|;
$th = $dbh->prepare($statement) or die DBI->errstr;
$th->execute( ) or die "Couldn't execute statement: $DBI::errstr; stopped";
$total_rating = $th->fetchrow_array();
$th->finish;
if ($total_rating)
{
$statement = qq|SELECT rating FROM perlDesk_reviews WHERE staff = "$staff_id"|;
$th = $dbh->prepare($statement) or die DBI->errstr;
$th->execute( ) or die "Couldn't execute statement: $DBI::errstr; stopped";
my $total_reviews = $th->rows();
$th->finish;
$template{'total_reviews'} = $total_reviews || "0";
my $crating = $total_rating/$total_reviews;
$crating = sprintf("%.0f", $crating);
$sc = $crating;
$sc = $sc+1;
# 4
for(1..$crating)
{
$template{'rating'} .= qq| |;
}
for ($sc..5)
{
$template{'rating'} .= qq| |;
}
} else {$template{'rating'} = "No Rating"; $template{'total_reviews'} = "0"; }
if ($closed > 0) {
$per = ($closed/$total)*100;
$perc = sprintf("%.2f",$per);
} else {
$perc = "0"
}
$statement = 'SELECT responsetime FROM perlDesk_staff WHERE username = "' . "$Cookies{'staff'}" . '"';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
while(my $ref = $sth->fetchrow_hashref())
{
$tsec = $ref->{'responsetime'};
}
if ($closed > 0)
{
$sec = ($tsec/$closed);
$days = int($sec/(24*60*60));
$hours = ($sec/(60*60))%24;
$mins = ($sec/60)%60;
$secs = $sec%60;
$restime = "$hours hr(s) $mins min(s) $secs seconds";
} else {
$restime = "No calls closed";
}
$template{'avgresp'} = $restime;
$template{'perc'} = $perc;
$template{'closed'} = $closed;
parse("$global{'data'}/include/tpl/staff/perf");
}
if ($section eq "listcalls")
{
check_user();
print "Content-type: text/html\n\n";
$status = $q->param('status');
$type = $status;
$template{'status'} = $status;
$department = $q->param('department');
if ($accesslevel !~ /$department}::/ && $accesslevel !~ /GLOB::/) { die_nice("Sorry $Cookies{'staff'}, You do not appear to have access to this department") if defined $department; }
if (defined $q->param('sort')) {
$sort = $q->param('sort');
} else { $sort = "id"; }
if (defined $q->param('method')) {
if ($q->param('method') eq "asc") { $method = "ASC"; } else { $method = "DESC"; }
}
else { $method = "ASC"; }
if ($q->param('timer'))
{
$template{'rtime'} = $q->param('timer');
$template{'t1'} = " selected" if $q->param('timer') == "60000";
$template{'t2'} = " selected" if $q->param('timer') == "180000";
$template{'t3'} = " selected" if $q->param('timer') == "300000";
$template{'t4'} = " selected" if $q->param('timer') == "900000";
$template{'t5'} = " selected" if $q->param('timer') == "1800000";
$template{'rdirector'} = ' onLoad=redirTimer()';
$template{'rurl'} = qq|&timer=| . $q->param('timer');
}
else { $template{'rdirector'} = ""; $template{'rurl'} = "";}
#~~
# Get The Number Of Open Tickets (Unresolved)
if ($status eq "open")
{
if ($accesslevel =~ /GLOB::/)
{
my $open_query = qq#SELECT COUNT(*) FROM perlDesk_calls WHERE status != "CLOSED"#;
$open_query .= qq# AND category = "$department"# if defined $q->param('department');
$sth = $dbh->prepare( $open_query ) or die DBI->errstr;
} else {
@access = split(/::/, $accesslevel);
$ac = 0;
foreach $dep (@access) { $ac++; }
$statement = 'SELECT COUNT(*) FROM perlDesk_calls WHERE status != "CLOSED" AND ';
$i = 1;
foreach $dep (@access)
{
$dep=~s/^\s+//g;
$statement .= 'category = "' . "$dep" . '" ';
if ($i < $ac) { $statement .= 'OR '; }
$i++;
}
$statement .= qq# AND category = "$department"# if defined $q->param('department');
$sth = $dbh->prepare($statement) or die DBI->errstr;
}
} else {
#~~
# View Closed Tickets (Resolved)
my $query = qq#SELECT COUNT(*) FROM perlDesk_calls WHERE status = "CLOSED"#;
$query .= qq# AND closedby = "$Cookies{'staff'}"# if !$q->param('filter');
$query .= qq# AND category = "$department"# if defined $q->param('department');
$sth = $dbh->prepare($query);
}
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
my ( $total ) = $sth->fetchrow_array();
if ($status eq "open" && defined $q->param('page'))
{
$page = $q->param('page');
execute_sql(qq|UPDATE perlDesk_staff SET lpage = "$page" WHERE username = "$Cookies{'staff'}"|);
}
if ($status eq "open" && !$q->param('page'))
{
$statement = 'SELECT lpage FROM perlDesk_staff WHERE username = ?';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute( $Cookies{'staff'} ) or die print "Couldn't execute statement: $DBI::errstr; stopped";
while(my $ref = $sth->fetchrow_hashref())
{
$page = $ref->{'lpage'};
}
}
$page = $q->param('page') || "0" if $status ne "open";
$limit = "30"; # Results per page
my $pages = ($total/$limit);
$pages = ($pages+0.5);
my $nume = sprintf("%.0f",$pages);
$nume = "1" if !$nume;
$to = ($limit * $page) if $page;
$to = "0" if !$page;
$tpage = $page;
$tpage = $tpage + 1;
$location = $page;
$location = $location + 1;
$lboundary = "1" if $location < 4;
$lboundary = $location - 3 if !$lboundary;
# Get Department List
$statement = 'SELECT level FROM perlDesk_departments';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
while(my $ref = $sth->fetchrow_hashref())
{
$template{'departments'} .= "{'level'}\">$ref->{'level'} " if $accesslevel =~ /$ref->{'level'}::/ || $accesslevel =~ /GLOB::/;
}
$sth->finish;
$nav .= qq|$nume Page(s): |;
if ($location + 2 < $nume) { $tboundary = 3 + $location; } else { $tboundary = $nume; }
$string = $ENV{'QUERY_STRING'};
$string =~ s/&page=(.*)//g;
$prev = $page;
$prev = $prev - 1;
if ($nume > 1 && $tpage > 1 ) { $nav .= qq|« |; }
foreach ($lboundary..$tboundary)
{
my $nu = $_ -1;
if ($nu eq $page) { $link = "[$_ ]"; } else { $link = "$_"; }
$nav .= qq|$link |;
}
$next = $page;
$next = $next + 1;
$last = $nume;
$last = $last - 1;
if ($tpage < $nume && $tpage >= 1) { $nav .= qq| » |; }
$template{'nav'} = $nav;
my $show = $limit * $page;
if ($status eq "open")
{
$template{'cc'} = "";
if ($accesslevel =~ /GLOB::/)
{
$statement = qq|SELECT * FROM perlDesk_calls WHERE status != "CLOSED"|;
$statement .= qq| AND category = "$department" | if defined $q->param('department');
$statement .= qq|ORDER BY $sort $method LIMIT $show, $limit|;
}
else {
@access = split(/::/,$accesslevel);
$ac = 0;
foreach $ddep (@access) { $ac++; }
$statement = 'SELECT * FROM perlDesk_calls WHERE (';
$i = 1;
foreach $dep (@access)
{
$dep=~s/^\s+//g;
$statement .= "category = \"$dep\" ";
if ($i < $ac) { $statement .= 'OR '; } else { $statement .= ")"; }
$i++;
}
$statement .= " AND status != \"CLOSED\" ORDER BY $sort $method LIMIT $show, $limit";
}
}
else {
$template{'cc'} = qq| FILTER: ( CLOSED BY ME / CLOSED BY ALL )|;
if ($q->param('filter') == "1")
{
if ($accesslevel =~ /GLOB::/)
{
$statement = qq|SELECT * FROM perlDesk_calls WHERE status = "CLOSED"|;
$statement .= qq| AND category = "$department" | if defined $q->param('department');
$statement .= qq|ORDER BY $sort $method LIMIT $show, $limit|;
}
else {
@access = split(/::/,$accesslevel);
$ac = 0;
foreach $ddep (@access) { $ac++; }
$statement = 'SELECT * FROM perlDesk_calls WHERE (';
$i = 1;
foreach $dep (@access)
{
$dep=~s/^\s+//g;
$statement .= "category = \"$dep\" ";
if ($i < $ac) { $statement .= 'OR '; } else { $statement .= ")"; }
$i++;
}
$statement .= " AND status = \"CLOSED\"";
$statement .= " AND category = \"$department\"" if defined $q->param('department');
$statement .= "ORDER BY $sort $method LIMIT $show, $limit";
}
} else {
$statement = "SELECT * FROM perlDesk_calls WHERE status = \"CLOSED\" AND closedby = \"$Cookies{'staff'}\"";
$statement .= " AND category = \"$department\" " if defined $q->param('department');
$statement .= "ORDER BY $sort $method LIMIT $show,$limit";
}
}
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement $stat: $DBI::errstr; stopped";
$sth->execute() or die print "Couldn't execute statement $stat: $DBI::errstr; stopped";
$number=0;
while($ref = $sth->fetchrow_hashref()) {
$number++;
$subject="$ref->{'subject'}";
$subject=substr($subject,0,20).'..' if length($subject) > 22;
$font = '#000000';
if ($ref->{'method'} eq "cc") { $img = "phone.gif"; } elsif ($ref->{'method'} eq "em") { $img = "mail.gif"; } else { $img = "ticket.gif"; }
if ($ref->{'priority'} eq "1") { $color = $global{'pri1'}; }
if ($ref->{'priority'} eq "2") { $color = $global{'pri2'}; }
if ($ref->{'priority'} eq "3") { $color = $global{'pri3'}; }
if ($ref->{'priority'} eq "4") { $color = $global{'pri4'}; }
if ($ref->{'priority'} eq "5") { $color = $global{'pri5'}; }
if ($ref->{'aw'} eq "1") { $awt = " "; } else { $awt = " "; }
$current_time = time();
$difference = $current_time - $ref->{'track'};
if ($difference >= 86400)
{
$period = "day";
$count = $difference / 86400;
}
elsif ($difference >= 3600)
{
$period = "hour";
$count = $difference / 3600;
}
elsif ($difference >= 60)
{
$period = "minute";
$count = $difference / 60;
}
else {
$period = "second";
$count = $difference;
}
$count = sprintf("%.0f", $count);
if ($count != 1) { $period .= "s"; }
$period .= " Ago";
if ($ref->{'ownership'} eq $Cookies{'staff'}) { $otag = ""; $ctag = " "; } else { $otag = ''; $ctag=''; }
$opencalls .= display_ticket($ref->{'id'}, $ref->{'username'}, $ref->{'category'}, $ref->{'status'});
}
$opencalls = '0 Requests Found
' if !$opencalls;
$template{'listcalls'} = $opencalls;
$template{'type'} = $status;
$template{'path'} = "staff.cgi" . '?' . $ENV{'QUERY_STRING'};
$template{'path'} =~ s/&sort=(.*)//;
$template{'path'} =~ s/&method=(.*)//;
parse("$global{'data'}/include/tpl/staff/listcalls");
}
exit;
}
sub function {
$action = "@_";
if ($action eq "history") {
$trackedcall = $q->param('callid');
$statement = 'SELECT * FROM perlDesk_calls WHERE id = ? ORDER BY id';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute($trackedcall) or die print "Couldn't execute statement: $DBI::errstr; stopped";
$number=0;
while(my $ref = $sth->fetchrow_hashref()) {
print qq|PerlDesk
Subject
$ref->{'subject'}
$ref->{description}
Responses
|;
}
$statemente = 'SELECT * FROM perlDesk_notes WHERE call = ? ORDER BY id;';
$sth = $dbh->prepare($statemente) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute($trackedcall) or die print "Couldn't execute statement: $DBI::errstr; stopped";
while(my $ref = $sth->fetchrow_hashref()) {
$body = $ref->{'comment'};
if ($body =~ /^) { } else { $body =~ s/\n/ /g; }
if ($ref->{'owner'} eq 0) {
print '
' . "$ref->{'author'}" . '
' . "$ref->{'time'}" . '
' . "$body" . '
';
}
if ($ref->{'owner'} eq 3) {
print '
' . "$ref->{'author'}" . '
' . "$ref->{'time'}" . '
' . "STAFF ACTION: $ref->{'action'} $body" . '
';
}
if ($ref->{'owner'} eq 1) {
if ($ref->{'visible'} eq 0) { $notice = 'PRIVATE STAFF NOTE '; } else { $notice = ''; }
print '
' . "$ref->{'author'}" . '
' . "$ref->{'time'}" . '
' . "$notice $body" . '
';
}
}
print qq|
|;
exit;
}
if ($action eq "print")
{
if (defined $q->param('callid')) {
$trackedcall = $q->param('callid');
print qq|$global{'title'}: Print Request |;
$statement = 'SELECT * FROM perlDesk_calls WHERE id = ?';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute($trackedcall) or die print "Couldn't execute statement: $DBI::errstr; stopped";
$number=0;
while(my $ref = $sth->fetchrow_hashref()) {
if (($accesslevel =~ /$ref->{'category'}::/) || ($accesslevel =~ /GLOB::/)) {
$trackno = $ref->{'id'};
$date = $ref->{'time'};
$username = $ref->{'username'};
$priority = $ref->{'priority'};
$status = $ref->{'status'};
$subject = $ref->{'subject'};
$category = $ref->{'category'};
$description = $ref->{'description'};
$owner = $ref->{'ownership'};
$number = 0;
$email = $ref->{'email'};
$url = $ref->{'url'};
$name = $ref->{'name'};
} else {
$error = 'You do not have permission to view this call';
push @errors, $error;
}
}
if (@errors) {
@content = @errors;
print @content;
exit;
}
print qq|
REQUEST ID $trackedcall
LOGGED: $date BY: $username
$subject
$description
ACTIONS/RESPONSES
|;
$statemente = 'SELECT * FROM perlDesk_notes WHERE call = ? ORDER BY id;';
$sth = $dbh->prepare($statemente) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute($trackedcall) or die print "Couldn't execute statement: $DBI::errstr; stopped";
while(my $ref = $sth->fetchrow_hashref()) {
$body = $ref->{'comment'};
if ($body =~ /^) {
# Do nothing
} else {
$body =~ s/\n/ /g;
}
if (($ref->{'owner'} eq 0) || ($ref->{'owner'} eq 1))
{
print qq|$ref->{'author'} $ref->{'time'} $body |;
}
if ($ref->{'owner'} eq 3)
{
print '
' . "$ref->{'author'}" . '
' . "$ref->{'time'}" . '
' . "STAFF ACTION: $ref->{'action'} $body" . '
';
}
}
print qq|
|;
} else
{
print "No call defined!";
exit;
}
exit;
}
if ($action eq "movedep") {
$callid = $q->param('callid');
$comments = $q->param('comment');
$dep = $q->param('select');
$tech = $q->param('assignstaff');
my @chars = ("A..Z","0..9","a..z");
$key = $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)] . $chars[rand(@chars)];
my $rv = $dbh->do(qq{INSERT INTO perlDesk_notes values (
"NULL", "3", "1", "ASSIGN", "$callid", "$staff_id", "$hdtime", "$key", "$comments", "$ENV{'REMOTE_ADDR'}")}
);
my $sdsth = $dbh->prepare( "INSERT INTO perlDesk_activitylog VALUES ( ?, ?, ?, ?, ?)" );
$sdsth->execute( "NULL", $callid, $hdtime, "Staff $Cookies{'staff'}", "Request Assigned Internal ($dep $tech)" ) or die "Couldn't execute statement: $DBI::errstr; stopped";
execute_sql(qq|UPDATE perlDesk_calls SET category = "$dep", ownership = "$tech" WHERE id = "$callid"|);
$response = "Thank you. Call ID $callid has been assigned to $dep
";
$template{'response'} = $response;
parse("$global{'data'}/include/tpl/staff/general");
exit;
}
if ($action eq "assign") {
$statement = 'SELECT level FROM perlDesk_departments';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
while(my $ref = $sth->fetchrow_hashref()) {
$option = "{'level'}\">$ref->{'level'} ";
push @list, $option;
}
$sth->finish;
push @slist, "Unassigned ";
$statement = 'SELECT username, name FROM perlDesk_staff';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute() or die print "Couldn't execute statement: $DBI::errstr; stopped";
while(my $ref = $sth->fetchrow_hashref()) {
$option = "{'username'}\">$ref->{'name'} ";
push @slist, $option;
}
$sth->finish;
$callid = $q->param('callid');
$response = 'Assign
Internal Below you
can assign this request to another department.
';
$template{'response'} = $response;
parse("$global{'data'}/include/tpl/staff/general");
exit;
}
if ($action eq 'addresponse')
{
if (defined $q->param('callid')) { $trackno = $q->param('callid'); }
else { $trackno = $q->param('ticket'); }
$statement = 'SELECT * FROM perlDesk_calls WHERE id = ? ORDER BY id';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute($trackno) or die print "Couldn't execute statement: $DBI::errstr; stopped";
$number=0;
while(my $ref = $sth->fetchrow_hashref())
{
if (($accesslevel =~ /$ref->{'category'}::/) || ($accesslevel =~ /GLOB::/))
{
$template{'trackno'} = $ref->{'id'};
$template{'date'} = $ref->{'time'};
$template{'uname'} = $ref->{'username'};
$template{'username'} = $ref->{'username'};
$template{'priority'} = $ref->{'priority'};
$template{'status'} = $ref->{'status'};
$template{'subject'} = $ref->{'subject'};
$template{'category'} = $ref->{'category'};
$template{'description'} = $ref->{'description'};
$template{'owned'} = $ref->{'ownership'};
$template{'number'} = 0;
$template{'email'} = $ref->{'email'};
$template{'url'} = $ref->{'url'};
$template{'name'} = $ref->{'name'};
} else {
$error= 'You do not have permission to view this call';
push @errors, $error;
}
}
$my_msg = $template{'description'};
$my_msg =~ s/ /\n/gi;
@msg = split(/\n/,$my_msg) if $q->param('inc') == "1";
foreach $lin (@msg) { $template{'msg'} .= qq|> $lin\n|; }
$template{'msg'} = "" if !$q->param('inc');
if ($template{'description'} =~ /^) { } else
{
# This is a Text Email, format it!
$template{'description'} =~ s/\n/ /g;
}
$statement = 'SELECT * FROM perlDesk_staff WHERE username = ?';
$sth = $dbh->prepare($statement) or die print "Couldn't prepare statement: $DBI::errstr; stopped";
$sth->execute("$Cookies{'staff'}") or die print "Couldn't execute statement: $DBI::errstr; stopped";
while(my $ref = $sth->fetchrow_hashref()
) {