} if ($mode == "find_client") { $term = trim(strip_tags($_POST['name'])); $stmt = $dbConnection->prepare('SELECT id FROM clients WHERE (fio LIKE :term) or (login LIKE :term2) or (tel LIKE :term3) limit 1'); $stmt->execute(array(':term' => '%' . $term . '%', ':term2' => '%' . $term . '%', ':term3' => '%' . $term . '%')); $res1 = $stmt->fetchAll(); if (!empty($res1)) { foreach ($res1 as $row) { $r['res'] = true; $r['p'] = $row['id']; } } if (empty($res1)) { $r['res'] = false; //user priv to add client in new ticket $pa = get_user_val('priv_add_client'); if ($pa == 1) { $r['priv'] = true; } if ($pa == 0) { $r['priv'] = false; } $r['msg_error'] = "<div class=\"alert alert-danger alert-dismissible\" role=\"alert\">\n <button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>\n " . lang('TICKET_error_msg') . "\n</div>"; } $row_set[] = $r; echo json_encode($row_set); } if ($mode == "get_client_from_new_t") { if (isset($_POST['get_client_info'])) { $client_id = $_POST['get_client_info']; get_client_info($client_id);
function get_client_info($id) { global $CONF; global $dbConnection; $stmt = $dbConnection->prepare('SELECT fio,tel,unit_desc,adr,tel_ext,email,login, posada, email FROM clients where id=:id'); $stmt->execute(array(':id' => $id)); $fio = $stmt->fetch(PDO::FETCH_ASSOC); $priv_edit_client = get_user_val('priv_edit_client'); $fio_user = $fio['fio']; $loginf = $fio['login']; $tel_user = $fio['tel']; $pod = $fio['unit_desc']; $adr = $fio['adr']; $tel_ext = $fio['tel_ext']; $mails = $fio['email']; $posada = $fio['posada']; $stmt = $dbConnection->prepare('select count(id) as t1 from tickets where client_id=:id'); $stmt->execute(array(':id' => $id)); $total_ticket = $stmt->fetch(PDO::FETCH_ASSOC); $tt = $total_ticket['t1']; $stmt = $dbConnection->prepare('select max(date_create) as dc from tickets where client_id=:id'); $stmt->execute(array(':id' => $id)); $last_ticket = $stmt->fetch(PDO::FETCH_ASSOC); $lt = $last_ticket['dc']; $uid = $_SESSION['helpdesk_user_id']; $priv_val = priv_status($uid); //echo $priv_edit_client; if ($priv_edit_client == 1) { $can_edit = true; } else { if ($priv_edit_client == 0) { $can_edit = false; } } //$can_edit=false; if ($can_edit == true) { ?> <div class="panel-heading"> <h4 class="panel-title"><i class="fa fa-user"></i> <?php echo lang('WORKER_TITLE'); ?> </h4> </div> <div class="panel-body"> <h4><center><strong><?php echo $fio_user; ?> </strong></center></h4> <table class="table "> <tbody> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_login'); ?> :</small></td> <td><small><a href="#" id="edit_login" data-type="text"><?php echo $loginf; ?> </a></small></td> </tr> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_posada'); ?> :</small></td> <td><small><a href="#" id="edit_posada" data-type="select" data-source="<?php echo $CONF['hostname']; ?> /inc/json.php?posada" data-pk="1" data-title="<?php echo lang('WORKER_posada'); ?> "><?php echo $posada; ?> </a></small></td> </tr> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_unit'); ?> :</small></td> <td><small><a href="#" id="edit_unit" data-type="select" data-source="<?php echo $CONF['hostname']; ?> /inc/json.php?units" data-pk="1" data-title="<?php echo lang('NEW_to_unit'); ?> "><?php echo $pod; ?> </a></small></td> </tr> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_tel'); ?> :</small></td> <td><small><a href="#" id="edit_tel" data-type="text"><?php echo $tel_user . " " . $tel_ext; ?> </a></small></td> </tr> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_room'); ?> :</small></td> <td><small><a href="#" id="edit_adr" data-type="text"><?php echo $adr; ?> </a></small></td> </tr> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_mail'); ?> :</small></td> <td><small><a href="#" id="edit_mail" data-type="text"><?php echo $mails; ?> </a></small></td> </tr> <tr> <td style=" width: 30px; "><small class="text-muted"><?php echo lang('WORKER_total'); ?> :</small></td> <td><small class="text-muted"> <?php if ($priv_val != "1") { ?> <a target="_blank" href="userinfo?user=<?php echo $id; ?> "><?php } echo $tt; if ($priv_val != "1") { ?> </a><?php } ?> </small></td> </tr> <?php if ($tt != 0) { ?> <tr> <td style=" width: 30px; "><small class="text-muted"><?php echo lang('WORKER_last'); ?> :</small></td> <td><small class="text-muted"> <?php if ($priv_val != "1") { ?> <a target="_blank" href="userinfo?user=<?php echo $id; ?> "> <?php } ?> <time id="b" datetime="<?php echo $lt; ?> "></time> <time id="c" datetime="<?php echo $lt; ?> "></time> <?php if ($priv_val != "1") { ?> </a><?php } ?> </small></td> </tr> <?php } ?> </tbody> </table> </div> <?php } if ($can_edit == false) { ?> <div class="panel-heading"> <h4 class="panel-title"><i class="fa fa-user"></i> <?php echo lang('WORKER_TITLE'); ?> </h4> </div> <div class="panel-body"> <h4><center><strong><?php echo $fio_user; ?> </strong></center></h4> <table class="table "> <tbody> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_login'); ?> :</small></td> <td><small><?php echo $loginf; ?> </small></td> </tr> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_posada'); ?> :</small></td> <td><small><?php echo $posada; ?> </small></td> </tr> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_unit'); ?> :</small></td> <td><small><?php echo $pod; ?> </small></td> </tr> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_tel'); ?> :</small></td> <td><small><?php echo $tel_user . " " . $tel_ext; ?> </small></td> </tr> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_room'); ?> :</small></td> <td><small><?php echo $adr; ?> </small></td> </tr> <tr> <td style=" width: 30px; "><small><?php echo lang('WORKER_mail'); ?> :</small></td> <td><small><?php echo $mails; ?> </small></td> </tr> <tr> <td style=" width: 30px; "><small class="text-muted"><?php echo lang('WORKER_total'); ?> :</small></td> <td><small class="text-muted"> <?php if ($priv_val != "1") { ?> <a target="_blank" href="userinfo?user=<?php echo $id; ?> "><?php } echo $tt; if ($priv_val != "1") { ?> </a><?php } ?> </small></td> </tr> <tr> <td style=" width: 30px; "><small class="text-muted"><?php echo lang('WORKER_last'); ?> :</small></td> <td><small class="text-muted"> <?php if ($priv_val != "1") { ?> <a target="_blank" href="userinfo?user=<?php echo $id; ?> "> <?php } echo $lt; if ($priv_val != "1") { ?> </a><?php } ?> </small></td> </tr> </tbody> </table> </div> <?php } }