<?php session_start(); include_once "../functions.inc.php"; if (priv_status($_SESSION['helpdesk_user_id']) == "0" || priv_status($_SESSION['helpdesk_user_id']) == "2") { if (isset($_POST['menu'])) { if ($_POST['menu'] == 'new') { if (isset($_GET['ok'])) { ?> <div class="alert alert-success"><?php echo lang('USERS_msg_add'); ?> </div> <?php } ?> <div class="panel panel-default" id="content_worker"> <div class="panel-heading"><?php echo lang('USERS_new'); ?> </div> <div class="panel-body"><div class="col-md-12"> <div class=""> <div class="panel-body">
<?php session_start(); include "../functions.inc.php"; if (validate_user($_SESSION['helpdesk_user_id'], $_SESSION['code'])) { if ($_SESSION['helpdesk_user_id']) { // include("head.inc.php"); // include("navbar.inc.php"); $priv_val = priv_status($_SESSION['helpdesk_user_id']); if ($priv_val == "2" || $priv_val == "0") { ?> <div class="container"> <input type="hidden" id="main_last_new_ticket" value="<?php echo get_last_ticket_new($_SESSION['helpdesk_user_id']); ?> "> <div class="page-header" style="margin-top: -15px;"> <div class="row"> <div class="col-md-6"> <h3><i class="fa fa-bar-chart-o"></i> <?php echo lang('ALLSTATS_main'); ?> </h3></div> </div> </div>
<div id="footer" > <div class="container-fluid"> <div class="col-md-8"> <p class="text-muted credit"><small>Designed by <a href="mailto:info@rustem.com.ua">Y.Snisar</a> (с) 2014.</p> </small> </div> <?php if (priv_status($_SESSION['helpdesk_user_id']) == "0") { $pri = "куратор"; } if (priv_status($_SESSION['helpdesk_user_id']) == "1") { $pri = "користувач"; } ?> <div class="col-md-4"> </div> </div> </div> <?php if ($lang == "ua") { $lang = "uk"; } ?> <!-- <script type="text/javascript"> var MyHOSTNAME = "<?php echo $CONF['hostname']; ?> ";
</center></p> </div> <?php } } ?> </div> <?php if (priv_status($user_id) == "0" || priv_status($user_id) == "2") { ?> <div class="text-center"><ul id="example_workers" class="pagination pagination-sm"></ul></div> <input type="hidden" id="cur_page" value="1"> <input type="hidden" id="total_pages" value="<?php echo get_total_pages_workers(); ?> "> <?php } ?> <?php } ?>
<?php } } if ($_POST['menu'] == 'arch') { $page = $_POST['page']; $perpage = '10'; if (isset($_SESSION['hd.rustem_list_arch'])) { $perpage = $_SESSION['hd.rustem_list_arch']; } $start_pos = ($page - 1) * $perpage; $user_id = id_of_user($_SESSION['helpdesk_user_login']); $unit_user = unit_of_user($user_id); $units = explode(",", $unit_user); $units = implode("', '", $units); $priv_val = priv_status($user_id); $ee = explode(",", $unit_user); $s = 1; foreach ($ee as $key => $value) { $in_query = $in_query . ' :val_' . $key . ', '; $s++; } $c = $s - 1; foreach ($ee as $key => $value) { $in_query2 = $in_query2 . ' :val_' . ($c + $key) . ', '; } $in_query = substr($in_query, 0, -2); $in_query2 = substr($in_query2, 0, -2); foreach ($ee as $key => $value) { $vv[":val_" . $key] = $value; }
?> <div class="alert alert-danger"><?php echo lang('TICKET_msg_unOK_error'); ?> </div> <?php } } if ($mode == "lock") { $user = $_POST['user']; $tid = $_POST['tid']; $stmt = $dbConnection->prepare('SELECT lock_by FROM tickets where id=:tid'); $stmt->execute(array(':tid' => $tid)); $fio = $stmt->fetch(PDO::FETCH_ASSOC); $lb = $fio['lock_by']; $ps = priv_status($lb); if ($lb == "0") { $stmt = $dbConnection->prepare('update tickets set lock_by=:user, last_update=now() where id=:tid'); $stmt->execute(array(':tid' => $tid, ':user' => $user)); $unow = $_SESSION['helpdesk_user_id']; $stmt = $dbConnection->prepare('INSERT INTO ticket_log (msg, date_op, init_user_id, ticket_id) values (:lock, now(), :unow, :tid)'); $stmt->execute(array(':tid' => $tid, ':unow' => $unow, ':lock' => 'lock')); ?> <div class="alert alert-success"><i class="fa fa-check"></i> <?php echo lang('TICKET_msg_lock'); ?> </div> <?php
function get_total_pages($menu, $id) { global $dbConnection; $perpage = '10'; if ($menu == "dashboard") { $perpage = '10'; if (isset($_SESSION['hd.rustem_list_in'])) { $perpage = $_SESSION['hd.rustem_list_in']; } $unit_user = unit_of_user($id); $priv_val = priv_status($id); $units = explode(",", $unit_user); $units = implode("', '", $units); $ee = explode(",", $unit_user); foreach ($ee as $key => $value) { $in_query = $in_query . ' :val_' . $key . ', '; } $in_query = substr($in_query, 0, -2); foreach ($ee as $key => $value) { $vv[":val_" . $key] = $value; } if ($priv_val == "0") { $res = $dbConnection->prepare("SELECT count(*) from tickets where unit_id IN (" . $in_query . ") and arch='0'"); $res->execute($vv); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($priv_val == "1") { $res = $dbConnection->prepare("SELECT count(*) from tickets where ((user_to_id=:id and arch='0') or (user_to_id='0' and unit_id IN (" . $in_query . ") and arch='0'))"); $paramss = array(':id' => $id); $res->execute(array_merge($vv, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($priv_val == "2") { $res = $dbConnection->prepare("SELECT count(*) from tickets where arch='0'"); $res->execute(); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } } } } if ($menu == "in") { $perpage = '10'; if (isset($_SESSION['hd.rustem_list_in'])) { $perpage = $_SESSION['hd.rustem_list_in']; } $unit_user = unit_of_user($id); $priv_val = priv_status($id); $units = explode(",", $unit_user); $units = implode("', '", $units); $ee = explode(",", $unit_user); foreach ($ee as $key => $value) { $in_query = $in_query . ' :val_' . $key . ', '; } $in_query = substr($in_query, 0, -2); foreach ($ee as $key => $value) { $vv[":val_" . $key] = $value; } if ($priv_val == "0") { if (isset($_SESSION['hd.rustem_sort_in'])) { if ($_SESSION['hd.rustem_sort_in'] == "ok") { $res = $dbConnection->prepare("SELECT count(*) from tickets where unit_id IN (" . $in_query . ") and arch='0' and status=:s"); $paramss = array(':s' => '1'); $res->execute(array_merge($vv, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_in'] == "free") { $res = $dbConnection->prepare("SELECT count(*) from tickets where unit_id IN (" . $in_query . ") and arch='0' and lock_by=:lb and status=:s"); $paramss = array(':lb' => '0', ':s' => '0'); $res->execute(array_merge($vv, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_in'] == "ilock") { $res = $dbConnection->prepare("SELECT count(*) from tickets where unit_id IN (" . $in_query . ") and arch='0' and lock_by=:lb"); $paramss = array(':lb' => $id); $res->execute(array_merge($vv, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_in'] == "lock") { $res = $dbConnection->prepare("SELECT count(*) from tickets where unit_id IN (" . $in_query . ") and arch='0' and (lock_by<>:lb and lock_by<>0) and (status=0)"); $paramss = array(':lb' => $id); $res->execute(array_merge($vv, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } } } } } if (!isset($_SESSION['hd.rustem_sort_in'])) { $res = $dbConnection->prepare("SELECT count(*) from tickets where unit_id IN (" . $in_query . ") and arch='0'"); $res->execute($vv); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } } else { if ($priv_val == "1") { if (isset($_SESSION['hd.rustem_sort_in'])) { if ($_SESSION['hd.rustem_sort_in'] == "ok") { $res = $dbConnection->prepare("SELECT count(*) from tickets where ((user_to_id=:id and arch='0') or (user_to_id='0' and unit_id IN (" . $in_query . ") and arch='0')) and status=:s"); $paramss = array(':id' => $id, ':s' => '1'); $res->execute(array_merge($vv, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_in'] == "free") { $res = $dbConnection->prepare("SELECT count(*) from tickets where ((user_to_id=:id and arch='0') or (user_to_id='0' and unit_id IN (" . $in_query . ") and arch='0')) and lock_by=:lb and status=:s"); $paramss = array(':id' => $id, ':lb' => '0', ':s' => '0'); $res->execute(array_merge($vv, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_in'] == "ilock") { $res = $dbConnection->prepare("SELECT count(*) from tickets where ((user_to_id=:id and arch='0') or (user_to_id='0' and unit_id IN (" . $in_query . ") and arch='0')) and lock_by=:lb"); $paramss = array(':id' => $id, ':lb' => $id); $res->execute(array_merge($vv, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_in'] == "lock") { $res = $dbConnection->prepare("SELECT count(*) from tickets where ((user_to_id=:id and arch='0') or (user_to_id='0' and unit_id IN (" . $in_query . ") and arch='0')) and (lock_by<>:lb and lock_by<>0) and (status=0)"); $paramss = array(':id' => $id, ':lb' => $id); $res->execute(array_merge($vv, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } } } } } if (!isset($_SESSION['hd.rustem_sort_in'])) { $res = $dbConnection->prepare("SELECT count(*) from tickets where ((user_to_id=:id and arch='0') or (user_to_id='0' and unit_id IN (" . $in_query . ") and arch='0'))"); $paramss = array(':id' => $id); $res->execute(array_merge($vv, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } } else { if ($priv_val == "2") { if (isset($_SESSION['hd.rustem_sort_in'])) { if ($_SESSION['hd.rustem_sort_in'] == "ok") { $res = $dbConnection->prepare("SELECT count(*) from tickets where arch='0' and status=:s"); $res->execute(array(':s' => '1')); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_in'] == "free") { $res = $dbConnection->prepare("SELECT count(*) from tickets where arch='0' and lock_by=:lb and status=:s"); $res->execute(array(':lb' => '0', ':s' => '0')); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_in'] == "ilock") { $res = $dbConnection->prepare("SELECT count(*) from tickets where arch='0' and lock_by=:lb"); $res->execute(array(':lb' => $id)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_in'] == "lock") { $res = $dbConnection->prepare("SELECT count(*) from tickets where arch='0' and (lock_by<>:lb and lock_by<>0) and (status=0)"); $res->execute(array(':lb' => $id)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } } } } } if (!isset($_SESSION['hd.rustem_sort_in'])) { $res = $dbConnection->prepare("SELECT count(*) from tickets where arch='0'"); $res->execute(); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } } } } } if ($menu == "out") { $perpage = '10'; if (isset($_SESSION['hd.rustem_list_out'])) { $perpage = $_SESSION['hd.rustem_list_out']; } if (isset($_SESSION['hd.rustem_sort_out'])) { if ($_SESSION['hd.rustem_sort_out'] == "ok") { $res = $dbConnection->prepare("SELECT count(*) from tickets where user_init_id=:id and arch='0' and status=:s"); $res->execute(array(':id' => $id, ':s' => '1')); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_out'] == "free") { $res = $dbConnection->prepare("SELECT count(*) from tickets where user_init_id=:id and arch='0' and lock_by=:lb and status=:s"); $res->execute(array(':id' => $id, ':lb' => '0', ':s' => '0')); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_out'] == "ilock") { $res = $dbConnection->prepare("SELECT count(*) from tickets where user_init_id=:id and arch='0' and lock_by=:lb"); $res->execute(array(':id' => $id, ':lb' => $id)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($_SESSION['hd.rustem_sort_out'] == "lock") { $res = $dbConnection->prepare("SELECT count(*) from tickets where user_init_id=:id and arch='0' and (lock_by<>:lb and lock_by<>0) and (status=0)"); $res->execute(array(':id' => $id, ':lb' => $id)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } } } } } if (!isset($_SESSION['hd.rustem_sort_out'])) { $res = $dbConnection->prepare("SELECT count(*) from tickets where user_init_id=:id and arch='0'"); $res->execute(array(':id' => $id)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } } if ($menu == "arch") { $perpage = '10'; if (isset($_SESSION['hd.rustem_list_arch'])) { $perpage = $_SESSION['hd.rustem_list_arch']; } $unit_user = unit_of_user($id); $priv_val = priv_status($id); $units = explode(",", $unit_user); $units = implode("', '", $units); $ee = explode(",", $unit_user); $s = 1; foreach ($ee as $key => $value) { $in_query = $in_query . ' :val_' . $key . ', '; $s++; } $c = $s - 1; foreach ($ee as $key => $value) { $in_query2 = $in_query2 . ' :val_' . ($c + $key) . ', '; } $in_query = substr($in_query, 0, -2); $in_query2 = substr($in_query2, 0, -2); foreach ($ee as $key => $value) { $vv[":val_" . $key] = $value; } foreach ($ee as $key => $value) { $vv2[":val_" . ($c + $key)] = $value; } if ($priv_val == "0") { $res = $dbConnection->prepare("SELECT count(*) from tickets where (unit_id IN (" . $in_query . ") or user_init_id=:id) and arch='1'"); $paramss = array(':id' => $id); $res->execute(array_merge($vv, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($priv_val == "1") { $res = $dbConnection->prepare("SELECT count(*) from tickets\n\t\t\t\t\t\t\twhere (user_to_id=:id and unit_id IN (" . $in_query . ") and arch='1') or\n\t\t\t\t\t\t\t(user_to_id='0' and unit_id IN (" . $in_query2 . ") and arch='1') or\n\t\t\t\t\t\t\t(user_init_id=:id2 and arch='1')"); $paramss = array(':id' => $id, ':id2' => $id); $res->execute(array_merge($vv, $vv2, $paramss)); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } else { if ($priv_val == "2") { $res = $dbConnection->prepare("SELECT count(*) from tickets where arch='1'"); $res->execute(); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } } } } if ($menu == "client") { $res = $dbConnection->prepare("SELECT count(*) from clients"); $res->execute(); $count = $res->fetch(PDO::FETCH_NUM); $count = $count[0]; } if ($count != 0) { $pages_count = ceil($count / $perpage); return $pages_count; } else { $pages_count = 0; return $pages_count; } return $count; }
</div> <?php $user_id = id_of_user($_SESSION['helpdesk_user_login']); $unit_user = unit_of_user($user_id); $ps = priv_status($user_id); $lo = "no"; /////////если пользователь/////////////////////////////////////////////////////////////////////////////////////////// if ($ps == 1) { //ЗАявка не выполнена ИЛИ выполнена мной //ЗАявка не заблокирована ИЛИ заблокирована мной if ($row['user_init_id'] == $user_id) { $lo = "yes"; } if ($row['user_init_id'] != $user_id) { if ($status_ok == 0 || $status_ok == 1 && $ok_by == $user_id) { if ($lock_by == 0 || $lock_by == $user_id) { $lo = "yes"; } } }