2013-08-28 22:47:04 +02:00
< ? php
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
/**
* File : userpanel_tickets . php .
* Author : Ulrich Block
* Contact : < ulrich . block @ easy - wi . com >
*
* This file is part of Easy - WI .
*
* Easy - WI is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* Easy - WI is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with Easy - WI . If not , see < http :// www . gnu . org / licenses />.
*
* Diese Datei ist Teil von Easy - WI .
*
* Easy - WI ist Freie Software : Sie koennen es unter den Bedingungen
* der GNU General Public License , wie von der Free Software Foundation ,
* Version 3 der Lizenz oder ( nach Ihrer Wahl ) jeder spaeteren
* veroeffentlichten Version , weiterverbreiten und / oder modifizieren .
*
* Easy - WI wird in der Hoffnung , dass es nuetzlich sein wird , aber
* OHNE JEDE GEWAEHELEISTUNG , bereitgestellt ; sogar ohne die implizite
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK .
* Siehe die GNU General Public License fuer weitere Details .
*
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
* Programm erhalten haben . Wenn nicht , siehe < http :// www . gnu . org / licenses />.
*/
2014-01-12 11:15:09 +01:00
2013-10-27 00:16:43 +02:00
if (( ! isset ( $user_id ) or $main != 1 ) or ( isset ( $user_id ) and ! $pa [ 'usertickets' ])) {
2013-08-28 22:47:04 +02:00
header ( 'Location: userpanel.php' );
die ;
}
2014-01-12 11:15:09 +01:00
2014-09-20 14:01:21 +02:00
$sprache = getlanguagefile ( 'tickets' , $user_language , $reseller_id );
2013-10-13 11:42:31 +02:00
$loguserid = $user_id ;
2013-10-26 11:59:03 +02:00
$logusername = getusername ( $user_id );
2013-09-29 15:29:58 +02:00
$logusertype = 'admin' ;
$logreseller = 0 ;
$logsubuser = 0 ;
2014-01-12 11:15:09 +01:00
2013-10-03 12:49:13 +02:00
if ( isset ( $admin_id ) and $reseller_id != 0 ) {
2013-10-05 18:39:30 +02:00
$reseller_id = $admin_id ;
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-10-03 16:48:54 +02:00
if ( $ui -> w ( 'action' , 4 , 'post' ) and ! token ( true )) {
2014-01-12 11:15:09 +01:00
2013-09-29 15:29:58 +02:00
$template_file = $spracheResponse -> token ;
2014-01-12 11:15:09 +01:00
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'd' , 'get' ) == 'ad' ) {
2014-01-12 11:15:09 +01:00
if ( ! $ui -> smallletters ( 'action' , 2 , 'post' )) {
2013-09-29 15:29:58 +02:00
$table = array ();
$table2 = array ();
2020-07-18 23:05:58 +02:00
$topic_require = true ;
2014-01-12 11:15:09 +01:00
$i = 1 ;
2013-10-13 11:42:31 +02:00
$default_language = $rSA [ 'language' ];
2014-01-12 11:15:09 +01:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT * FROM `ticket_topics` WHERE `maintopic`=`id` AND `resellerid`=? ORDER BY id " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $reseller_id ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2013-10-03 12:49:13 +02:00
$topic = '' ;
2014-01-12 11:15:09 +01:00
2013-09-29 15:29:58 +02:00
$query3 = $sql -> prepare ( " SELECT `text` FROM `translations` WHERE `type`='ti' AND `lang`=? AND `transID`=? AND `resellerID`=? LIMIT 1 " );
2014-09-20 14:01:21 +02:00
$query3 -> execute ( array ( $user_language , $row [ 'id' ], $reseller_id ));
2013-10-13 11:42:31 +02:00
$topic = $query3 -> fetchColumn ();
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
if ( empty ( $topic )) {
2014-09-20 14:01:21 +02:00
$query3 -> execute ( array ( $default_language , $row [ 'id' ], $reseller_id ));
2013-10-13 11:42:31 +02:00
$topic = $query3 -> fetchColumn ();
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
if ( empty ( $topic )) {
2013-10-13 11:42:31 +02:00
$topic = $row [ 'topic' ];
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2020-07-18 23:05:58 +02:00
if ( empty ( $topic )) {
$row [ 'id' ] = 0 ;
$topic = $sprache -> error_no_topic ;
}
2013-10-10 08:06:37 +02:00
$table [] = array ( 'id' => $row [ 'id' ], 'topic' => $topic );
2014-01-12 11:15:09 +01:00
if ( $i == 1 ) {
2013-09-29 15:29:58 +02:00
$query2 = $sql -> prepare ( " SELECT * FROM `ticket_topics` WHERE `maintopic`=? AND `maintopic`!=`id` AND `resellerid`=? ORDER BY `id` " );
2014-09-20 14:01:21 +02:00
$query2 -> execute ( array ( $row [ 'id' ], $reseller_id ));
2014-11-30 12:55:07 +01:00
while ( $row2 = $query2 -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-12 11:15:09 +01:00
2013-10-03 12:49:13 +02:00
$topic = '' ;
2014-01-12 11:15:09 +01:00
2014-09-20 14:01:21 +02:00
$query3 -> execute ( array ( $user_language , $row2 [ 'id' ], $reseller_id ));
2013-10-13 11:42:31 +02:00
$topic = $query3 -> fetchColumn ();
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
if ( empty ( $topic )) {
2014-09-20 14:01:21 +02:00
$query3 -> execute ( array ( $default_language , $row2 [ 'id' ], $reseller_id ));
2013-10-13 11:42:31 +02:00
$topic = $query3 -> fetchColumn ();
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
if ( empty ( $topic )) {
2013-10-13 11:42:31 +02:00
$topic = $row2 [ 'topic' ];
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-10-10 08:06:37 +02:00
$table2 [] = array ( 'id' => $row2 [ 'id' ], 'topic' => $topic );
2013-08-28 22:47:04 +02:00
}
2020-07-18 23:05:58 +02:00
if ( ! isset ( $table2 ) || empty ( $table2 )){
$table2 [] = array ( 'id' => 0 , 'topic' => $sprache -> error_no_topic2 );
$topic_require = false ;
}
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
$i ++ ;
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2020-07-18 23:05:58 +02:00
if ( ! isset ( $table ) || empty ( $table )){
$table [] = array ( 'id' => 0 , 'topic' => $sprache -> error_no_topic );
$table2 [] = array ( 'id' => 0 , 'topic' => $sprache -> error_no_topic2 );
}
2014-01-12 11:15:09 +01:00
$template_file = 'userpanel_tickets_add.tpl' ;
2014-09-20 12:21:54 +02:00
} else if ( $ui -> smallletters ( 'action' , 2 , 'post' ) == 'ad' ) {
2020-07-18 23:05:58 +02:00
if ( $ui -> id ( 'topic' , 30 , 'post' ) || $ui -> post [ 'topic' ] == 0 ) {
if ( $ui -> post [ 'topic' ] == 0 ){
$topic = $ui -> post [ 'maintopic' ];
} else {
$topic = $ui -> id ( 'topic' , 30 , 'post' );
}
2014-09-20 12:21:54 +02:00
$userPriority = $ui -> id ( 'userPriority' , 30 , 'post' );
$ticketText = htmlentities ( $ui -> post [ 'ticket' ]);
$query = $sql -> prepare ( " SELECT `priority` FROM `ticket_topics` WHERE `id`=? AND `resellerid`=? LIMIT 1 " );
2014-09-20 14:01:21 +02:00
$query -> execute ( array ( $topic , $reseller_id ));
2014-09-20 12:21:54 +02:00
$priority = $query -> fetchColumn ();
$query = $sql -> prepare ( " INSERT INTO `tickets` (`topic`,`userid`,`priority`,`userPriority`,`writedate`,`resellerid`) VALUES (?,?,?,?,?,?) " );
2014-09-20 14:01:21 +02:00
$query -> execute ( array ( $topic , $user_id , $priority , $userPriority , $logdate , $reseller_id ));
2014-09-20 12:21:54 +02:00
$lastID = $sql -> lastInsertId ();
$query = $sql -> prepare ( " INSERT INTO `tickets_text` (`ticketID`,`writeDate`,`userID`,`message`,`resellerID`) VALUES (?,?,?,?,?) " );
2014-09-20 14:01:21 +02:00
$query -> execute ( array ( $lastID , $logdate , $user_id , $ticketText , $reseller_id ));
2014-09-20 12:21:54 +02:00
if ( $reseller_id == 0 ) {
$query = $sql -> prepare ( " SELECT `id`,`mail_ticket` FROM `userdata` WHERE `resellerid`='0' AND `accounttype`='a' " );
$query -> execute ();
} else {
$query = $sql -> prepare ( " SELECT `id`,`mail_ticket` FROM `userdata` WHERE `id`=? AND `id`=`resellerid` " );
$query -> execute ( array ( $reseller_id ));
}
2014-01-12 11:15:09 +01:00
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2020-07-18 23:05:58 +02:00
if ( $row [ 'mail_ticket' ] == 'Y' ) sendmail ( 'emailnewticket' , $row [ 'id' ], $ticketText , array ( $lastID , $user_id , $topic ));
2014-09-20 12:21:54 +02:00
}
2014-01-12 11:15:09 +01:00
2014-09-20 12:21:54 +02:00
$template_file = $spracheResponse -> table_add ;
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
} else {
2014-09-20 12:21:54 +02:00
$template_file = $sprache -> error_topic ;
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
} else {
2013-09-29 15:29:58 +02:00
$template_file = 'userpanel_404.tpl' ;
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
} else if ( $ui -> st ( 'd' , 'get' ) == 'md' and $ui -> id ( 'id' , 19 , 'get' )) {
$id = $ui -> id ( 'id' , 19 , 'get' );
2013-10-13 11:42:31 +02:00
if ( $ui -> st ( 'action' , 'get' ) == 'cl' ) {
2014-01-12 11:15:09 +01:00
2013-09-29 15:29:58 +02:00
$template_file = 'userpanel_tickets_close.tpl' ;
2014-01-12 11:15:09 +01:00
2013-10-13 11:42:31 +02:00
} else if ( $ui -> st ( 'action' , 'get' ) == 'op' ) {
2014-01-12 11:15:09 +01:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " UPDATE `tickets` SET `state`='R' WHERE `id`=? AND `userid`=? AND `resellerid`=? AND `state`='D' LIMIT 1 " );
2014-09-20 14:01:21 +02:00
$query -> execute ( array ( $id , $user_id , $reseller_id ));
2014-01-12 11:15:09 +01:00
2013-11-24 12:12:07 +01:00
$template_file = ( $query -> rowCount () > 0 ) ? $spracheResponse -> table_add : $spracheResponse -> error_table ;
2014-01-12 11:15:09 +01:00
} else if ( ! $ui -> smallletters ( 'action' , 2 , 'post' ) or $ui -> smallletters ( 'action' , 2 , 'get' ) == 'md' ) {
2013-09-29 15:29:58 +02:00
$table = array ();
2013-10-13 11:42:31 +02:00
$default_language = $rSA [ 'language' ];
2014-01-12 11:15:09 +01:00
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT * FROM `tickets` WHERE `id`=? AND `userid`=? AND `resellerid`=? LIMIT 1 " );
2014-08-17 22:33:31 +02:00
$query2 = $sql -> prepare ( " SELECT t.*,u.`cname`,u.`name`,u.`vname` FROM `tickets_text` t LEFT JOIN `userdata` u ON t.`userID`=u.`id` WHERE t.`ticketID`=? AND t.`resellerID`=? ORDER BY t.`writeDate` DESC " );
2013-09-29 15:29:58 +02:00
$query3 = $sql -> prepare ( " SELECT `text` FROM `translations` WHERE `type`='ti' AND `lang`=? AND `transID`=? AND `resellerID`=? LIMIT 1 " );
$query4 = $sql -> prepare ( " SELECT `topic` FROM `ticket_topics` WHERE `id`=? AND `resellerid`=? LIMIT 1 " );
2014-01-12 11:15:09 +01:00
2014-09-20 14:01:21 +02:00
$query -> execute ( array ( $id , $user_id , $reseller_id ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-12 11:15:09 +01:00
$userPriority = $row [ 'userPriority' ];
2014-08-17 22:33:31 +02:00
$query2 -> execute ( array ( $id , $reseller_id ));
2014-11-30 12:55:07 +01:00
while ( $row2 = $query2 -> fetch ( PDO :: FETCH_ASSOC )) {
2014-09-13 14:53:13 +02:00
$table [] = array ( 'writedate' => ( $user_language == 'de' ) ? date ( 'd.m.Y' , strtotime ( $row2 [ 'writeDate' ])) : date ( 'Y-m-d' , strtotime ( $row2 [ 'writeDate' ])), 'writeTime' => date ( 'H:i:s' , strtotime ( $row2 [ 'writeDate' ])), 'ticket' => nl2br ( htmlspecialchars ( stripslashes ( $row2 [ 'message' ]))), 'writer' => ( trim ( $row2 [ 'vname' ] . ' ' . $row2 [ 'name' ]) != '' ) ? trim ( $row2 [ 'vname' ] . ' ' . $row2 [ 'name' ]) : $row2 [ 'cname' ]);
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
if ( $row [ 'userPriority' ] == 1 ) {
$priority = $sprache -> priority_low ;
} else if ( $row [ 'userPriority' ] == 2 ) {
$priority = $sprache -> priority_medium ;
} else if ( $row [ 'userPriority' ] == 3 ) {
$priority = $sprache -> priority_high ;
} else if ( $row [ 'userPriority' ] == 4 ) {
$priority = $sprache -> priority_very_high ;
} else {
$priority = $sprache -> priority_critical ;
}
if ( $row [ 'state' ] == 'A' ) {
$status = $sprache -> status_author ;
} else if ( $row [ 'state' ] == 'C' ) {
$status = $sprache -> status_confirmed ;
} else if ( $row [ 'state' ] == 'D' ) {
$status = $sprache -> status_done ;
} else if ( $row [ 'state' ] == 'N' ) {
$status = $sprache -> status_new ;
} else if ( $row [ 'state' ] == 'P' ) {
$status = $sprache -> status_process ;
} else {
$status = $sprache -> status_reopen ;
}
if ( $row [ 'state' ] == 'C' ) {
$open = 'N' ;
} else if ( $row [ 'state' ] == 'D' ) {
$open = 'D' ;
} else {
$open = 'Y' ;
}
2013-08-28 22:47:04 +02:00
if ( is_numeric ( $row [ 'topic' ])) {
2014-01-12 11:15:09 +01:00
2013-09-29 15:29:58 +02:00
$topic = '' ;
2014-01-12 11:15:09 +01:00
2014-09-20 14:01:21 +02:00
$query3 -> execute ( array ( $user_language , $row [ 'id' ], $reseller_id ));
2013-10-13 11:42:31 +02:00
$topic = $query3 -> fetchColumn ();
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
if ( empty ( $topic )) {
2014-09-20 14:01:21 +02:00
$query3 -> execute ( array ( $default_language , $row [ 'id' ], $reseller_id ));
2013-10-13 11:42:31 +02:00
$topic = $query3 -> fetchColumn ();
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
if ( empty ( $topic )) {
2014-09-20 14:01:21 +02:00
$query4 -> execute ( array ( $row [ 'topic' ], $reseller_id ));
2014-01-12 11:15:09 +01:00
$topic = stripslashes ( $query4 -> fetchColumn ());
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
if ( empty ( $topic )) {
2014-01-12 11:15:09 +01:00
$topic = stripslashes ( $row [ 'topic' ]);
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
} else {
2013-10-13 11:42:31 +02:00
$topic = $row [ 'topic' ];
2013-08-28 22:47:04 +02:00
}
}
2014-01-12 11:15:09 +01:00
if ( isset ( $priority )) {
2014-09-13 14:53:13 +02:00
$lastdate = '' ;
2014-01-12 11:15:09 +01:00
$template_file = ( $ui -> smallletters ( 'action' , 2 , 'get' ) == 'md' ) ? 'userpanel_tickets_md.tpl' : 'userpanel_tickets_view.tpl' ;
} else {
$template_file = 'userpanel_404.tpl' ;
}
} else if ( $ui -> smallletters ( 'action' , 2 , 'post' ) == 'wr' ) {
2020-07-20 23:22:16 +02:00
$query = $sql -> prepare ( " SELECT `supporter`,`state`,`topic` FROM `tickets` WHERE `id`=? AND `resellerid`=? LIMIT 1 " );
2014-09-20 14:01:21 +02:00
$query -> execute ( array ( $id , $reseller_id ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2013-10-13 11:42:31 +02:00
$userid = $row [ 'supporter' ];
$state = $row [ 'state' ];
2020-07-20 23:22:16 +02:00
$topicid = $row [ 'topic' ];
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
if ( isset ( $state ) and $state != 'C' ) {
2014-01-12 11:23:27 +01:00
$affectedRows = 0 ;
2014-01-12 11:15:09 +01:00
if ( $ui -> id ( 'userPriority' , 1 , 'post' )) {
2013-10-03 12:49:13 +02:00
$query = ( $state == 'A' ) ? $sql -> prepare ( " UPDATE `tickets` SET `state`='P',`userPriority`=? WHERE `id`=? AND `resellerid`=? LIMIT 1 " ) : $sql -> prepare ( " UPDATE `tickets` SET `userPriority`=? WHERE `id`=? AND `resellerid`=? LIMIT 1 " );
2014-01-12 11:15:09 +01:00
$query -> execute ( array ( $ui -> id ( 'userPriority' , 1 , 'post' ), $id , $reseller_id ));
2014-01-12 11:23:27 +01:00
$affectedRows += $query -> rowCount ();
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
if ( isset ( $ui -> post [ 'ticket' ]) and strlen ( $ui -> post [ 'ticket' ]) > 0 ) {
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " INSERT INTO `tickets_text` (`ticketID`,`message`,`writeDate`,`userID`,`resellerid`) VALUES (?,?,?,?,?) " );
2014-09-20 14:01:21 +02:00
$query -> execute ( array ( $id , $ui -> post [ 'ticket' ], $logdate , $user_id , $reseller_id ));
2014-01-12 11:15:09 +01:00
2014-01-12 11:23:27 +01:00
$affectedRows += $query -> rowCount ();
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2014-01-12 11:23:27 +01:00
$template_file = ( $affectedRows > 0 ) ? $spracheResponse -> table_add : $spracheResponse -> error_table ;
2014-01-12 11:15:09 +01:00
if ( isid ( $userid , 10 )) {
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " SELECT `mail_ticket` FROM `userdata` WHERE `id`=? LIMIT 1 " );
2013-08-28 22:47:04 +02:00
$query -> execute ( array ( $userid ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-12 11:15:09 +01:00
if ( $row [ 'mail_ticket' ] == 'Y' ) {
2020-07-20 23:22:16 +02:00
sendmail ( 'emailnewticket' , $userid , $ui -> post [ 'ticket' ], array ( $id , $user_id , $topicid ));
2014-01-12 11:15:09 +01:00
}
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
} else {
2013-09-29 15:29:58 +02:00
$template_file = 'userpanel_404.tpl' ;
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
} else if ( $ui -> smallletters ( 'action' , 2 , 'post' ) == 'cl' and $ui -> id ( 'rating' , 1 , 'post' )) {
2013-09-29 15:29:58 +02:00
$query = $sql -> prepare ( " UPDATE `tickets` SET `state`='C', `rating`=?,`comment`=? WHERE `id`=? AND `userid`=? AND `resellerid`=? AND `state`!='C' LIMIT 1 " );
2014-09-20 14:01:21 +02:00
$query -> execute ( array ( $ui -> id ( 'rating' , 1 , 'post' ), $ui -> description ( 'comment' , 'post' ), $id , $user_id , $reseller_id ));
2014-01-12 11:15:09 +01:00
2013-11-24 12:12:07 +01:00
$template_file = ( $query -> rowCount () > 0 ) ? $spracheResponse -> table_add : $spracheResponse -> error_table ;
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
} else {
2014-01-12 11:15:09 +01:00
2013-09-29 15:29:58 +02:00
$table = array ();
2014-01-12 11:15:09 +01:00
$ticketLinks [ 'all' ] = 'userpanel.php?w=ti&d=md&a=' . $ui -> id ( 'a' , 3 , 'get' );
2013-10-03 12:49:13 +02:00
$ticketLinks [ 'amount' ] = 'userpanel.php?w=ti&d=md' ;
2014-01-12 11:15:09 +01:00
$ticketLinks [ 'A' ] = 'userpanel.php?w=ti&d=md&a=' . $ui -> id ( 'a' , 3 , 'get' );
$ticketLinks [ 'C' ] = 'userpanel.php?w=ti&d=md&a=' . $ui -> id ( 'a' , 3 , 'get' );
$ticketLinks [ 'D' ] = 'userpanel.php?w=ti&d=md&a=' . $ui -> id ( 'a' , 3 , 'get' );
$ticketLinks [ 'N' ] = 'userpanel.php?w=ti&d=md&a=' . $ui -> id ( 'a' , 3 , 'get' );
$ticketLinks [ 'P' ] = 'userpanel.php?w=ti&d=md&a=' . $ui -> id ( 'a' , 3 , 'get' );
$ticketLinks [ 'R' ] = 'userpanel.php?w=ti&d=md&a=' . $ui -> id ( 'a' , 3 , 'get' );
$where = 'WHERE t.`userid`=? AND t.`resellerid`=?' ;
2013-08-28 22:47:04 +02:00
if ( isset ( $ui -> get [ 'ts' ])) {
foreach ( $ui -> get [ 'ts' ] as $get ) {
2014-01-12 11:15:09 +01:00
if ( preg_match ( '/[ACDNPR]/' , $get )) {
$selected [] = $get ;
}
2013-08-28 22:47:04 +02:00
}
} else {
2014-01-12 11:15:09 +01:00
$selected = array ( 'A' , 'D' , 'N' , 'P' , 'R' );
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
$temp = ' AND (' ;
2013-09-29 15:29:58 +02:00
$i = 0 ;
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
foreach ( $selected as $get ) {
2014-01-12 11:15:09 +01:00
2023-05-19 11:49:08 +03:30
$temp .= ( $i == 0 ) ? " `state`=' { $get } ' " : " OR `state`=' { $get } ' " ;
2014-01-12 11:15:09 +01:00
2013-10-05 13:39:56 +02:00
$selected [] = $get ;
2014-01-12 11:15:09 +01:00
2013-08-28 22:47:04 +02:00
$i ++ ;
}
2014-01-12 11:15:09 +01:00
2013-10-13 11:42:31 +02:00
$temp .= ')' ;
2014-01-12 11:15:09 +01:00
if ( $i != 0 ) {
$where .= $temp ;
}
2013-10-26 11:59:03 +02:00
foreach ( $ticketLinks as $k => $v ) {
2013-08-28 22:47:04 +02:00
foreach ( array ( 'A' , 'C' , 'D' , 'N' , 'P' , 'R' ) as $s ) {
2014-01-12 11:15:09 +01:00
if (( in_array ( $s , $selected ) and $k != $s ) or ( ! in_array ( $s , $selected ) and $k == $s )) {
$ticketLinks [ $k ] .= '&ts[]=' . $s ;
}
2013-08-28 22:47:04 +02:00
}
}
2014-01-12 11:15:09 +01:00
2014-08-18 22:58:32 +02:00
$query = $sql -> prepare ( " SELECT t.*,l.`text`,d.`text` AS `defaultsubject`,u.`cname`,u.`name`,u.`vname` FROM `tickets` t LEFT JOIN `ticket_topics` o ON t.`topic`=o.`id` LEFT JOIN `translations` l ON o.`id`=l.`transID` AND l.`type`='ti' AND l.`lang`=? LEFT JOIN `translations` d ON t.`id`=d.`transID` AND d.`type`='ti' AND d.`lang`=? LEFT JOIN `userdata` u ON t.`supporter`=u.`id` " . $where );
$query -> execute ( array ( $user_language , $default_language , $user_id , $reseller_id ));
2014-11-30 12:55:07 +01:00
while ( $row = $query -> fetch ( PDO :: FETCH_ASSOC )) {
2014-01-12 11:15:09 +01:00
if ( $row [ 'userPriority' ] == 1 ) {
$priority = $sprache -> priority_low ;
} else if ( $row [ 'userPriority' ] == 2 ) {
$priority = $sprache -> priority_medium ;
} else if ( $row [ 'userPriority' ] == 3 ) {
$priority = $sprache -> priority_high ;
} else if ( $row [ 'userPriority' ] == 4 ) {
$priority = $sprache -> priority_very_high ;
} else {
$priority = $sprache -> priority_critical ;
}
2013-08-28 22:47:04 +02:00
if ( is_numeric ( $row [ 'topic' ])) {
2013-09-29 15:29:58 +02:00
$topic = '' ;
2013-10-03 12:49:13 +02:00
if ( $row [ 'text' ] != null and $row [ 'text' ] != '' ) {
2013-10-13 11:42:31 +02:00
$topic = $row [ 'text' ];
2013-10-03 12:49:13 +02:00
} else if ( $row [ 'defaultsubject' ] != null or $row [ 'defaultsubject' ] != '' ) {
2013-10-13 11:42:31 +02:00
$topic = $row [ 'defaultsubject' ];
2013-08-28 22:47:04 +02:00
} else {
2013-10-13 11:42:31 +02:00
$topic = $row [ 'topic' ];
2013-08-28 22:47:04 +02:00
}
} else {
2013-10-13 11:42:31 +02:00
$topic = $row [ 'topic' ];
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2013-10-03 12:49:13 +02:00
if ( $user_language == 'de' ) {
2014-01-12 11:15:09 +01:00
$writedate = date ( 'd.m.Y H:i:s' , strtotime ( $row [ 'writedate' ]));
2013-08-28 22:47:04 +02:00
} else {
2013-10-13 11:42:31 +02:00
$writedate = $row [ 'writedate' ];
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
$statusClass = 'warning' ;
2013-10-03 12:49:13 +02:00
if ( $row [ 'state' ] == 'A' ) {
2013-10-13 11:42:31 +02:00
$status = $sprache -> status_author ;
2013-08-28 22:47:04 +02:00
$statusClass = 'info' ;
2013-10-03 12:49:13 +02:00
} else if ( $row [ 'state' ] == 'C' ) {
2013-10-13 11:42:31 +02:00
$status = $sprache -> status_confirmed ;
2013-08-28 22:47:04 +02:00
$statusClass = 'success' ;
2013-10-03 12:49:13 +02:00
} else if ( $row [ 'state' ] == 'D' ) {
2013-10-13 11:42:31 +02:00
$status = $sprache -> status_done ;
2013-08-28 22:47:04 +02:00
$statusClass = 'success' ;
2013-10-03 12:49:13 +02:00
} else if ( $row [ 'state' ] == 'N' ) {
2013-10-13 11:42:31 +02:00
$status = $sprache -> status_new ;
2013-10-03 12:49:13 +02:00
} else if ( $row [ 'state' ] == 'P' ) {
2013-10-13 11:42:31 +02:00
$status = $sprache -> status_process ;
2013-08-28 22:47:04 +02:00
} else {
2013-10-13 11:42:31 +02:00
$status = $sprache -> status_reopen ;
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
$table [] = array ( 'id' => $row [ 'id' ], 'priority' => $priority , 'writedate' => $writedate , 'supporter' => ( trim ( $row [ 'vname' ] . ' ' . $row [ 'name' ]) != '' ) ? trim ( $row [ 'vname' ] . ' ' . $row [ 'name' ]) : $row [ 'cname' ], 'subject' => $topic , 'status' => $status , 'rawState' => $row [ 'state' ], 'statusClass' => $statusClass );
2013-08-28 22:47:04 +02:00
}
2014-01-12 11:15:09 +01:00
2014-08-18 22:58:32 +02:00
configureDateTables ( '-1' , '5, "desc"' );
2014-01-12 11:15:09 +01:00
2014-08-18 22:58:32 +02:00
$template_file = 'userpanel_tickets_list.tpl' ;
2013-08-28 22:47:04 +02:00
}