Вход Регистрация
Файл: billing/_rootbill/_tickets.inc.php
Строк: 382
<?
    _head
('utf-8',$_lang[TicketsTitle]);
//    print "<H1 class=pagetitle>".$_lang[TicketsTitle]."</H1><hr class=hr>";

    
if (GetSetting("ticketsEnable")) {

    if (
$sub == "delete" and $id and GetSetting("ticketsUsersCanDelete")) {
        
$r=@mysql_query("select * from tickets where id='$id' and userid=".$_SESSION["userId"]) or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
        if (
mysql_num_rows($r) > 0) {
            @
mysql_query("delete from tickets where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
            @
mysql_query("delete from tickets where parentid='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
            print 
$_lang[TicketsDeleteSuccess]."<br><br>";

            print 
"[ <a class=rootlink href=?do=tickets>".$_lang[TicketsGotoTicketsList]."</a> ]<BR><BR>";
        } else {
            
$sub "";
        }
    }

    if (
$sub == "close" and $id) {
        
$z = @mysql_query("select * from tickets where status='closed' and id='$id' and userid=".$_SESSION["userId"]) or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
        if (
mysql_num_rows($z) == 0) {
            @
mysql_query("update tickets set status='closed' where id='$id' and userid=".$_SESSION["userId"]) or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
            @
mysql_query("insert into tickets (parentid,dt,userid,message) values('$id',NOW(),'".$_SESSION["userId"]."','Тикет закрыт клиентом.')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
            print 
$_lang[TicketsCloseSuccess]."<br><br>";

            print 
"[ <a class=rootlink href=?do=tickets&sub=view&id=$id>".$_lang[TicketsGoBackToTicket]."</a> ] [ <a class=rootlink href=?do=tickets>".$_lang[TicketsGotoTicketsList]."</a> ]<BR><BR>";
        } else {
            
$sub "";
        }
    }

    if (
$sub == "new") {
        if (!
$subject) { print "<font color=red>".$_lang[TicketsErrorSubject]."</font><br><br>"; }
        else if (
$priority == '') { print "<font color=red>".$_lang[TicketsErrorPriority]."</font><br><br>"; }
        else if (!
$message) { print "<font color=red>".$_lang[TicketsErrorMessage]."</font><br><br>"; }
        else {
            
$z=@mysql_query("select * from tickets where parentid='0' and priority='$priority' and subject='$subject' and userid='".$_SESSION["userId"]."' and message='$message'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
            if (
mysql_num_rows($z) > 0) {
                
$sub "";
            } else {
                @
mysql_query("insert into tickets (priority,dt,subject,userid,message,department) values('$priority',NOW(),'$subject','".$_SESSION["userId"]."','$message','$department')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
                
$ticketid=mysql_insert_id();
                
$support_email=GetSetting("support_email");

                
$subject_msg "[#$ticketid] New ticket [важность ".$_priority[$priority]."]";
                
$message "Пользователь ".$_SESSION["userLogin"]." открыл новый тикет "$subject" (ID # $ticketid)nnПерейти к тикету можно по ссылке: ".$full_www_path.$admin_script."?do=tickets&sub=view&id=$ticketidnnСообщение:nn$message";

                
$admEmails=GetAdminEmailsWhereTrueParam("sendticket",$department);
                if (
count($admEmails) > 0) {
                    
WriteMailLog($subject_msg,$message);
                }
                
sendmail($support_email,'',$support_email,$subject_msg,$message);

                print 
$_lang[TicketsNewSuccess]."<br><br>";

                print 
"[ <a class=rootlink href=?do=tickets&sub=view&id=$ticketid>".$_lang[TicketsGotoNewTicket]."</a> ] [ <a class=rootlink href=?do=tickets>".$_lang[TicketsGotoTicketsList]."</a> ]<BR><BR>";
            }
        }
    }

    if (
$sub == "reply") {
        if (!
$id) {print "<font color=red>".$_lang[ErrorBadId]."</font><br><br>";}
        else {
            
$r=@mysql_query("select * from tickets where id='$id' and userid='".$_SESSION["userId"]."'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
            if (
mysql_num_rows($r) == 0) {print "<font color=red>".$_lang[TicketsErrorNoTicket]."</font><br><br>";}
            else if (!
$message) { print "<font color=red>".$_lang[TicketsErrorMessage]."</font><br><br>";}
            else { 
                
$z=@mysql_query("select * from tickets where parentid='$id' and userid='".$_SESSION["userId"]."' and message='$message'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
                if (
mysql_num_rows($z) > 0) {
                    
$sub "";
                } else {
                    @
mysql_query("update tickets set newforadmin='1',status='open' where id='$id' and userid=".$_SESSION["userId"]) or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
                    @
mysql_query("insert into tickets (parentid,dt,userid,message) values('$id',NOW(),'".$_SESSION["userId"]."','$message')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());

                    
$ticket=GetTicketById($id);
                    
$support_email=GetSetting("support_email");

                    
$subject "[#$id] Reply to ticket [важность ".$_priority[$ticket->priority]."]";
                    
$message "Пользователь ".$_SESSION["userLogin"]." добавил новое сообщение в тикет "".$ticket->subject."" (ID # $id)nnПерейти к тикету можно по ссылке: ".$full_www_path.$admin_script."?do=tickets&sub=view&id=$idnnСообщение:nn$message";

                    
$admEmails=GetAdminEmailsWhereTrueParam("sendticket",$ticket->department);
                    if (
count($admEmails) > 0) {
                        
WriteMailLog($subject,$message);
                    }
                    
sendmail($support_email,'',$support_email,$subject,$message);

                    
$message="";
                    print 
$_lang[TicketsReplySuccess]."<br><br>";

                    print 
"[ <a class=rootlink href=?do=tickets&sub=view&id=$id>".$_lang[TicketsGoBackToTicket]."</a> ] [ <a class=rootlink href=?do=tickets>".$_lang[TicketsGotoTicketsList]."</a> ]<BR><BR>";
                }
            }
        }
    }

    if (
$sub == "view") {
        if (!
$id) {print "<font color=red>".$_lang[ErrorBadId]."</font><br><br>";}
        else {
            
$r=@mysql_query("select * from tickets where id='$id' and userid='".$_SESSION["userId"]."'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
            
$r2=@mysql_query("select t1.* from tickets as t1, tickets as t2 where t1.parentid='$id' and t2.id=t1.parentid and t2.userid='".$_SESSION["userId"]."' order by t1.id") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());

            if (
mysql_num_rows($r) == 0) {print "<font color=red>".$_lang[TicketsErrorNoTicket]."</font><br><br>";}
            else {
                @
mysql_query("update tickets set newforuser='0' where id='$id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());

                print 
"<table class='rpTable' cellpadding=3 border=1>";
                while (
$rr mysql_fetch_object($r) or $rr = @mysql_fetch_object($r2)) {
                    
$cnt++;

                    if (
$cnt == and ($rr->adminname or $rr->adminId)) { $firstMsgByAdmin true; }

                    if (
$rr->userid and !$rr->adminId and !$rr->adminname) {
                        if (!
$firstMsgByAdmin) { $type=$_lang[TicketsTicketTypeMsg]; } else { $type=$_lang[TicketsTicketTypeReply]; }
                        
$img="<img src="./_rootimages/ticket_user.gif">";
                    } else {
                        if (
$rr->adminId) {
                            
$admin GetAdminById($rr->adminId);
                            if (
$admin->name) {
                                
$adminNameT=" ($admin->name)";
                            } else if (
$rr->adminname) {
                                
$adminNameT=" ($rr->adminname)";
                            } else {
                                
$adminNameT="";
                            }
                        } else if (
$rr->adminname) {
                            
$adminNameT=" ($rr->adminname)";
                        } else {
                            
$adminNameT="";
                        }

                        if (
$firstMsgByAdmin) {    $type=$_lang[TicketsTicketTypeMsg]; } else { $type=$_lang[TicketsTicketTypeReply]; }
                        
$type=$type."$adminNameT"

                        
$img="<img src="./_rootimages/ticket_admin.gif">";
                    }
                    if (
$cnt == 1) {
                        
$priority="| ".$_lang[TicketsPriority].": <img src="./_rootimages/priority_".$rr->priority.".gif" alt="".$_lang[TicketsPriority]." ".$_priority[$rr->priority]."">";
                        
$status="| ".$_lang[TicketsStatus].": <img src="./_rootimages/ticket_".$rr->status.".gif" alt="".$_lang[TicketsTicket]." ".$_statusTicket[$rr->status]."">";

                        print 
"<tr><th align=center colspan=2>".$_lang[TicketsTicketView].": <B>".$rr->subject."</b></th></tr>";
                    } else {
$priority="";$status="";}
                    
$rr->message preg_replace("/rn/ui""<BR>"$rr->message);

                    print 
"<tr><th colspan=2><b>#$cnt $type</b> | ".$_lang[TicketsDate].": $rr->dt $priority $status</td></tr>";
                    print 
"<tr bgcolor=$font_row1><th valign=top width=60>$img</th><td valign=top>$rr->message<Br><br></td></tr>";
                }

                print 
"</table>";

                
?>
                <br>
                    <table class='rpTable' border=1><form method=post action="billing.php">
                    <tr><th colspan=2 align=center><?=$_lang[TicketsAddMessage]?></b></th></tr>
                    <input type=hidden name=do value=<?=$do?>>
                    <input type=hidden name=sub value=reply>
                    <input type=hidden name=id value=<?=$id?>>
                    <tr><th valign=top><?=$_lang[TicketsTicketTypeMsg]?>:</th><td><textarea class=input name=message cols=70 rows=10><?=$message?></textarea></td></tr>
                    <tr><th colspan=2 align=center><input class=button type=Submit value="<?=$_lang[Add]?>"></th></tr></table></form>
                <?

            
}
        }
    }

    if (!
$sub) {
        if (!
$status or $status == "open") {$status="and (status='open' or status='wait')"$statustxt=$_lang[TicketsStatusOpen];}
        else if (
$status == "wait") {$status="and status='wait'"$statustxt=$_lang[TicketsStatusWait];}
        else if (
$status == "all") {$status=""$statustxt=$_lang[TicketsStatusAll];}
        else {
$status="and status='closed'"$statustxt=$_lang[TicketsStatusClosed];}

        
$ticketsUsersCanDelete GetSetting("ticketsUsersCanDelete");

            
?>
            <table class='rpTable' cellpadding=3 width=95% align=center border=1>
            <tr><th colspan=6 align=center><B><?=$_lang[TicketsYourTickets]?> [ <?=$statustxt?> ]</b></th></tr>
        <tr><th colspan=6 align=center><?=$_lang[TicketsShow]?>: [ <a class=rootlink href=?do=tickets&status=all><?=$_lang[TicketsStatusAll]?></a> ] [ <a class=rootlink href=?do=tickets&status=open><?=$_lang[TicketsStatusOpen]?></a> ] [ <a class=rootlink href=?do=tickets&status=closed><?=$_lang[TicketsStatusClosed]?></a> ] [ <a class=rootlink href=?do=tickets&status=wait><?=$_lang[TicketsStatusWait]?></a> ]</th></tr>
            <tr align=center><th>#</th><th><?=$_lang[Indication]?></th><th><?=$_lang[TicketsSubject]?></th><th><?=$_lang[TicketsDate]?></th><th><?=$_lang[TicketsTicketReplys]?></th><th><?=$_lang[Option]?></th></tr>
            <?
            $r
=@mysql_query("select * from tickets where userid='".$_SESSION["userId"]."' $status and parentid=0 order by newforuser desc, id desc") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
            
$cnt=0;
            while (
$rr mysql_fetch_object($r)) {
            
getfont();
            
$cnt++;

            
$subj=$rr->subject; if ($rr->newforuser) {$subj="<b>$subj</b>";}
            
$dt split(' '$rr->dt); $dt=mydate($dt[0]);

            
$replys=@mysql_query("select COUNT(*) as cnt from tickets where parentid='$rr->id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
            
$replys=mysql_fetch_object($replys);

            
$link="?do=$do&sub=view&id=$rr->id";
            if (
$ticketsUsersCanDelete) { $delete="<A class=rootlink href=?do=$do&sub=delete&id=$rr->id onclick="javascript: return confirm('".$_lang[TicketsDeleteAlert]."');"><img src=./_rootimages/del.gif border=0 alt='".$_lang[TicketsDelete]."'></a><BR>"; } else { $delete=''; }
            
$close="<A class=rootlink href=?do=$do&sub=close&id=$rr->id onclick="javascript: return confirm('".$_lang[TicketsCloseAlert]."');"><img src=./_rootimages/close.gif border=0 alt='".$_lang[TicketsClose]."'></a>";

            
?>
            <tr bgcolor="<?=$font_row?>" height=30>
            <td valign=middle>&nbsp;<?=$cnt?>&nbsp;</td>
            <td valign=middle>&nbsp;<img src="./_rootimages/priority_<?=$rr->priority?>.gif" alt="<?=$_lang[TicketsPriority]?> <?=$_priority[$rr->priority]?>"> <img src="./_rootimages/ticket_<?=$rr->status?>.gif" alt="<?=$_lang[TicketsTicket]?> <?=$_statusTicket[$rr->status]?>">&nbsp;</td>
            <td>&nbsp;<a class=rootlink href=<?=$link?>><?=$subj?></a>&nbsp;</td>
            <td>&nbsp;<?=$dt?>&nbsp;</td>
            <td align=center><?=$replys->cnt?></td>
            <td align=center><?=$delete?> <?if ($rr->status == "open") {print $close;}?></td>
            </tr>
            <?
        
}
        
?>
        <tr><th colspan=6><?=$_lang[TicketsTotalTickets]?><?=$cnt?></th></td></tr>
        </table><br>

            <table class='rpTable' border=1 align=center><form method=post action="billing.php">
            <tr><th colspan=2 align=center><?=$_lang[TicketsNewTicket]?></th></tr>
            <input type=hidden name=do value=<?=$do?>>
            <input type=hidden name=sub value=new>
            <tr><th><?=$_lang[TicketsSubject]?>:</th><td><input class=input type=text size=73 maxlength=50 name=subject value="<?=$subject?>" size=49></td></tr>
        <?
        $admGroups 
GetAdminGroups();
        if (@
mysql_num_rows($admGroups) > 0) {
            print 
"<tr><th>".$_lang[TicketsDepartment].":</th><td><select class=input name=department>";
            while (
$admGroup = @mysql_fetch_object($admGroups)) {
                print 
"<option value=$admGroup->id$admGroup->name ";
            }
            print 
"</select></td></tr>";
        }
        
?>
            <tr><th><?=$_lang[TicketsPriority]?>:</th><td><?GetPrioritySelect($priority)?></td></tr>
            <tr><th valign=top><?=$_lang[TicketsTicketTypeMsg]?>:</th><td><textarea class=input name=message cols=70 rows=10><?=$message?></textarea></td></tr>
            <tr><th colspan=2 align=center><input class=button type=Submit value="<?=$_lang[TicketsAddTicket]?>"></td></tr></table></form>
        <?
    
}
    } else {
        print 
$_lang[TicketsDisabled];
    }

    
_foot('utf-8');    
?>
Онлайн: 1
Реклама