<?php
    /*-------------------------
    Autor: Amner Saucedo Sosa
    Web: www.abisoftgt.net
    E-Mail: waptoing7@gmail.com
    ---------------------------*/

 include "header.php";

if (isset($_GET['id']) && !empty($_GET['id'])){
        $id=intval($_GET["id"]);
        $id=intval($_GET["id"]);
    } else {
        print "<script>window.location='tickets.php?error'</script>";
    }

    //$id = intval($_GET['id']);
    $sql = mysqli_query($con, "select * from tickets where id=$id");
    $rows= mysqli_fetch_array($sql);
        $name= $rows['name'];
        $email= $rows['email'];
        $phone= $rows['phone'];
        $cell_phone= $rows['cell_phone'];
        $contact_schedule= $rows['contact_schedule'];
        $kind_id= $rows['kind_id'];
        $comment= $rows['comment'];
        $image= $rows['image'];
        $area= $rows['area'];
        $asunt= $rows['asunt'];
        $id_team= $rows['id_team'];
        $pass_team= $rows['pass_team'];
        $client_id= $rows['client_id'];
        $created_at= $rows['created_at'];
        $status_id= $rows['status_id'];
        $number_ticket= $rows['number_ticket'];
        $asigned_id= $rows['asigned_id'];
        $atendido= $rows['date_atendid'];
        $sistema= $rows['sistema'];
        $finalizado=$rows['finalizado'];
        $tipo_requerimiento=$rows['tipo_requerimiento'];
        $date_asigned=$rows['date_asigned'];



    if (mysqli_num_rows($sql)==0) {
       //header("location: tickets.php");
        print "<script>window.location='tickets.php'</script>";
    }

    //tipo requerimiento
    //if ($tipo_requerimiento!=0) {
        $requerimientos=mysqli_query($con, "select * from tipos_requerimientos where id=$tipo_requerimiento");

        $rows=mysqli_fetch_array($requerimientos);
           $name_require=$rows['name'];

   // }

    if ($asigned_id!=0) {
        $user_id=$asigned_id;
        $user=mysqli_query($con, "select * from user where id=$user_id");

        $row=mysqli_fetch_array($user);
           $name_user=$row['name'];
           $lastname_user=$row['lastname'];


    }

    $status=mysqli_query($con, "select * from status where id=$status_id");

    $service=mysqli_query($con, "select * from area where id=$area");
    $rows1=mysqli_fetch_array($service);
       $servicio=$rows1['name'];

    $rows=mysqli_fetch_array($status);
       $name_status=$rows['name'];


?>

      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <section class="content-header">
            <!-- <h1>
              <i class="fa fa-edit icon-title"></i> Agregar Ticket
            </h1> -->
            <ol class="breadcrumb">
              <li><a href="tickets.php"><i class="fa fa-ticket"></i> Tickets </a></li>
              <li class="active"> Detalles Ticket</li>
            </ol>
        </section>
        <br><br>
        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-12">
                    <a href="tickets.php" class="btn btn-default  pull-right"><i class="glyphicon glyphicon-arrow-left"></i> Regresar</a>
                </div>
                <br>
                <br>
            </div>
            <div class="row">
                <div class="col-md-3"></div>
                <div class="panel panel-danger col-md-2">
                    <div class="panel-heading">
                        <h3 class="panel-title">REGISTRADO POR</h3>
                    </div>
                    <div class="panel-body">
                        <?php echo $name ?>
                    </div>
                </div>
                <div class="col-md-0"></div>
                <?php if($asigned_id!=0){ ?>
                <div class="panel panel-warning col-md-2">
                    <div class="panel-heading">
                        <h3 class="panel-title">ASIGNADO</h3>
                    </div>
                    <div class="panel-body">
                        <?php echo $date_asigned ?>
                    </div>
                </div>
                <?php }else{ ?>
                    <div class="panel panel-danger col-md-2">
                    <div class="panel-heading">
                        <h3 class="panel-title">ASIGNADO</h3>
                    </div>
                    <div class="panel-body">
                       En espera
                    </div>
                </div>
                <?php } ?>
                <div class="col-md-0"></div>
                    <?php if($atendido!="0000-00-00 00:00:00"){ ?>
                    <div class="panel panel-success col-md-2">
                        <div class="panel-heading">
                            <h3 class="panel-title">ATENDIDO</h3>
                        </div>
                        <div class="panel-body">
                            <?php echo $atendido ?>
                        </div>
                    </div>
                    <?php }else{ ?>
                    <div class="panel panel-danger col-md-2">
                        <div class="panel-heading">
                            <h3 class="panel-title">ATENDIDO</h3>
                        </div>
                        <div class="panel-body">
                           En espera
                        </div>
                    </div>
                    <?php } ?>
            </div>
                <div class="row">
                    <div class="col-md-2"></div>
                    <!-- <?php if($sistema!=""){ ?>
                    <div class="panel panel-info col-md-3">
                        <div class="panel-heading">
                            <h3 class="panel-title">SISTEMA</h3>
                        </div>
                        <div class="panel-body">
                            <?php echo $sistema ?>
                        </div>
                    </div>
                    <?php }else{ ?>
                    <div class="panel panel-danger col-md-3">
                        <div class="panel-heading">
                            <h3 class="panel-title">MENSAJE</h3>
                        </div>
                        <div class="panel-body">
                            Sin actividad
                        </div>
                    </div>
                    <?php } ?>Main content -->
                </div>




            <div class="row">
                <div class="col-md-1"></div>
                <div class="col-md-10">
                    <div class="box box-success">
                        <!-- form start -->
                        <form role="form" class="form-horizontal" action="action/addticket.php" method="POST" enctype="multipart/form-data">
                            <div class="box-body">
                                <?php
                                    $kinds=mysqli_query($con, "select * from kind where id=$kind_id");
                                    if ($row=mysqli_fetch_array($kinds)) {
                                        $name_kind=$row['name'];
                                    }
                                ?>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;">Área:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="<?php echo $name_kind ?>" readonly>
                                        </div>
                                    </div>
                                
                                <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;" >Servicio:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="<?php echo $servicio  ?>" readonly>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;">Usuario:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="<?php echo $name ?>" readonly>
                                        </div>
                                    </div>
                                    <!--Añadir la extensión, correo, horario y teamviewer (ID y contraseña) -->
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;">Correo:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="<?php echo $email  ?>" readonly>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;">Extensi&oacute;n:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="<?php echo $phone  ?>" readonly>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;">Teléfono
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="<?php echo $cell_phone  ?>" readonly>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;">Horario:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="<?php echo $contact_schedule  ?>" readonly>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;">ID AnyDesk:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="<?php echo $id_team  ?>" readonly>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;">Contrase&ntilde;a:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="<?php echo $pass_team  ?>" readonly>
                                        </div>
                                    </div>



                                    <!--<div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" >Version y Modulo:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="<?php echo "2.0" ?>" readonly>
                                        </div>
                                    </div> -->
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;" >Descripción:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <textarea style="resize: none;" class="form-control col-md-7 col-xs-12" readonly><?php echo  $comment ?></textarea>
                                        </div>
                                    </div>
                                <!--
                                    <h2>ASIGNACIÓN DEL REQUEMIENTOS</h2>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" >Tipo del Requerimiento Reportado:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                        <?php if($tipo_requerimiento==0){?>
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="" readonly>
                                        <?php }else{ ?>
                                            <input type="text" class="form-control col-md-7 col-xs-12" value="<?php echo $name_require ?>" readonly>
                                        <?php } ?>
                                        </div>
                                    </div> -->
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;" >Agente de soporte asignado:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                        <?php if($asigned_id==0){ ?>
                                            <input type="text"  class="form-control col-md-7 col-xs-12" value="Sin asignar" readonly>
                                        <?php }else{ ?>
                                            <input type="text"  class="form-control col-md-7 col-xs-12" value="<?php echo $name_user." ".$lastname_user ?>" readonly>
                                        <?php } ?>
                                        </div>
                                    </div>
                                     <h2>ATENCIÓN BRINDADA</h2>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;" >Tipo de atención:
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text"  class="form-control col-md-7 col-xs-12" value="<?php echo "SOPORTE TÉCNICO" ?>" readonly>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12" style="font-weight: bold;"  >Detalle de la atención
                                        </label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                         <?php if($finalizado==""){?>
                                            <textarea style="resize: none;" class="form-control col-md-7 col-xs-12" readonly><?php echo "EN ESPERA..." ?></textarea>
                                        <?php
                                        }else{
                                        ?>
                                            <textarea style="resize: none;" style="color: red" class="alert alert-warning form-control col-md-7 col-xs-12" readonly><?php echo $finalizado ?></textarea>
                                        <?php
                                        }
                                        ?>
                                        </div>
                                    </div>
                               </div>
                        </form>
                    </div><!-- /.box -->
                </div><!--/.col -->
            </div>   <!-- /.row -->
        </section><!-- /.content -->
    </div>
  <?php include "footer.php" ?>
