<?php
    /*-------------------------
    Autor: Romario Hdz
    :)
    Web: www.abisoftgt.net
    E-Mail: waptoing7@gmail.com
    ---------------------------*/
    include "header.php";
    $kinds =mysqli_query($con, "select * from kind order by id desc");
    
  
    
    
    $areas =mysqli_query($con, "select * from area");
    
    $consulta = "select * from area inner join kind where area.id = kind.id";
    
?>

      <!-- 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"> Nuevo Ticket </li>
            </ol>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-2"></div>
                <div class="col-md-8">
                    <?php
                        if (isset($_GET)) {

                            if (isset($_GET['success'])) {
                                echo "<div class='alert alert-success' role='alert'><strong>Exito!</strong> Ticket creado con éxito.</div>";
                            }
                            if (isset($_GET['error'])) {
                                 echo "<div class='alert alert-danger' role='alert'><strong>¡Error!</strong>El ticket no pudo crearse.</div>";
                            }
                        }
                    ?>
                </div>
            </div>
            <div class="row">
                <div class="col-md-10">
                    <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-2"></div>
                <div class="col-md-8">
                    <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">
                                <div>
                                    <p align="right">
                                        <b>Los campos con * son obligatorios</b>
                                    </p>
                                </div>
                                

                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Nombre <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9 col-sm-9 col-xs-12">
                                        <input type="text" name="name" id="name" class="form-control" placeholder="Nombre" required value="<?php echo $fullname ?>" readonly>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">E-mail <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9 col-sm-9 col-xs-12">
                                        <input type="email" name="email" id="email" class="form-control" placeholder="E-mail" required  value="<?php echo $email ?>" readonly>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="phone">Extensi&oacute;n <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9 col-sm-9 col-xs-12">
                                        <input type="text" name="phone" id="phone" class="form-control" placeholder="Extensión"  required>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="phone2">Celular
                                    </label>
                                    <div class="col-md-9 col-sm-9 col-xs-12">
                                        <input type="text" name="phone2" id="phone2" class="form-control" placeholder="Celular" >
                                    </div>
                                </div>


                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12">Horario de contacto<span class="required">*</span></label>

                                    <div class="col-md-9 col-sm-9 col-xs-12">

                                      <input type="text" name="contact" class="form-control" placeholder="8:30 am - 6:30 pm"  required>
                                      <!--<input type="radio" class="flat" name="contact" id="gender1" value="1" checked  required />  08:00am - 01:00pm-->
                                      
                                    </div>
                                </div>



                                <div class="form-group" style="display: none;" id="asunto">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="asunt">Asunto <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9 col-sm-9 col-xs-12">
                                        <input type="text" name="asunt" id="asunt" class="form-control" placeholder="Asunto" >
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class=" control-label col-md-3 col-sm-3 col-xs-12" for="kind_id">Área <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9 col-sm-9 col-xs-12">
                                        <select class="chosen-select form-control" name="kind_id"  id="kind_id" required placeholder="-- Seleccionar --" autocomplete="off" >
                                             
			    
			    <!--<option value="" >Seleccione una opción</option>-->
				<option value="2">CCTV</option>
				<option value="3">Celulares</option>
				<option value="4">Compras IT</option>
				<option value="5">CONTPAQ</option>
				<option value="6">HelpDesk</option>
				<option value="7">Office 365</option>
				<option value="8">Redes</option>
				<option value="9">SAI</option>
				<option value="10">SEINTRA</option>
				<option value="11">Servidores</option>
				<option value="12">Soporte Técnico</option>
				<option value="13">Telefonía</option>
				
				<option value="1">Otro</option>
				
				
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class=" control-label col-md-3 col-sm-3 col-xs-12" for="area">Servicio <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9 col-sm-9 col-xs-12">
                                        <div id="select2lista">
                                            
                                        </div>
                                    </div>
                                    </div>
                                <div class="form-group">
                                    <label for="comment" class="control-label col-md-3 col-sm-3 col-xs-12">Descripción <span class="required">*</span>
                                    </label>
                                    <div class="col-md-9 col-sm-9 col-xs-12">
                                      <textarea name="comment" id="comment" class="form-control col-md-7 col-xs-12"  placeholder="Favor de agregar una explicación de tu problema o solicitud" required style="resize:none;"></textarea>
                                      <div>
                                        Si requieres apoyo para registrar tu ticket puedes enviarnos un correo a soporte@clisa.com o al número 81 4000 9023
                                    </div>
                                    </div>
                                </div>
                                <br>
                                <p class="text-info text-center">Si usa AnyDesk nos ayudara mucho que brinde sus datos:</p>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="id_team">ID de AnyDesk
                                    </label>
                                    <div class="col-md-9 col-sm-9 col-xs-12">
                                        <input type="text" name="id_team" id="id_team" class="form-control" placeholder="ID de AnyDesk" >
                                    </div>
                                </div>
                               <!-- <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12" for="pass_team">Contraseña
                                    </label>
                                    <div class="col-md-9 col-sm-9 col-xs-12">
                                        <input type="text" name="pass_team" id="pass_team" class="form-control" placeholder="Contraseña de TeamViewer" >
                                    </div>
                                    
                                </div>-->
                                <!--<div class="form-group">
                                    <label class="col-sm-3 col-md-3 control-label">Adjunto</label>
                                    <div class="col-sm-9">
                                        <input type="file" name="image">
                                        <p class="text-muted">Peso Máximo 2MB</p>
                                    </div>
                                </div>-->

                            </div><!-- /.box body -->
                            <div class="box-footer">
                                <div class="form-group">
                                    <div class="col-sm-offset-2 col-sm-10">
                                        <input type="submit" class="btn btn-success btn-submit" name="token" value="Guardar">
                                        <a href="tickets.php" class="btn btn-default btn-reset">Cancelar</a>
                                    </div>
                                </div>
                            </div><!-- /.box footer -->
                        </form>
                    </div><!-- /.box -->
                </div><!--/.col -->
            </div>   <!-- /.row -->
        </section><!-- /.content -->
    </div>
    <?php include "footer.php" ?>
    
     
<script
	src="https://code.jquery.com/jquery-3.3.1.min.js"
	integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
	crossorigin="anonymous">
    
</script>

<script type="text/javascript">
	$(document).ready(function(){
		$('#kind_id').val(2);
		recargarLista();

		$('#kind_id').change(function(){
			recargarLista();
		});
	})
</script>
<script type="text/javascript">
	function recargarLista(){
		$.ajax({
			type:"POST",
			url:"datos.php",
			data:"continente=" + $('#kind_id').val(),
			success:function(r){
				$('#select2lista').html(r);
			}
		});
	}
</script>

    
<script>
    //funcion para el tipo de persona (nuevo cliente)
    $(function(){
    $("select[name=kind_id]").change(function(){
        if($('select[name=kind_id]').val()==1){
          //  $("#juridica").css("display","none");//ocultamos el inpput
            $("#asunto").css("display","block");//mostramos el inpput
            //$('input[name=natural]').val($(this).val());

        }
        if($('select[name=kind_id]').val()!=1){
          //  $("#juridica").css("display","block"); //mostramos el inpput
            $("#asunto").css("display","none"); //ocultamos el inpput
          //  $('input[name=juridica]').val($(this).val());

        }
    });
    })
</script>
