<?

include("../Librerias/ConfNivel2.inc");

$Nivel=$_Nivel2;

$ObjSesion=new Sesiones();   //Clase Sesin

$ObjSesion->MVerifica($Nivel);

$Conexion=new DBAccess();

$Conexion->Acceso($Servidor,$UsuarioBD,$ClaveBD,$BaseDatos);

$Formulario=new Formulario();

$FechaActual = date("Y-m-d");

//FEncabezado($Nivel);

/*Obtenemos los valores por get*/ 

$tags2 = array_keys($_GET); // obtiene los nombres de las variables

$valores2 = array_values($_GET);// obtiene los valores de las variables

$i=0;

foreach ($_GET as $valores){

 ${$tags2[$i]}=$valores;

 $i++;	

}

//valores del post	  

if ($_POST){ 

$tags2 = array_keys($_POST); // obtiene los nombres de las variables

$valores2 = array_values($_POST);// obtiene los valores de las variables

$i=0;

foreach ($_POST as $valores){

 ${$tags2[$i]}=$valores;

 $i++;	

}

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//ES" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

  <html xmlns="http://www.w3.org/1999/xhtml">

    <head> 

		<meta name="viewport" content="width=device-width, initial-scale=1, charset=utf-8">

		<link rel="stylesheet" type="text/css" href="<? echo $Nivel ?>bootstrap/css/bootstrap.css">    

         <?

	   if ($_JQuery == 1)

echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>';

else

echo '<script src="'.$Nivel.'bootstrap/js/jquery.min.js"></script>';

 echo "<link rel='stylesheet' type='text/css' media='all' href='".$Nivel."Scripts/calendar-blue.css' title='win2k-1' />";

        echo "<script type='text/javascript' src='".$Nivel."Scripts/calendar.js'></script>";

        echo "<script type='text/javascript' src='".$Nivel."Scripts/calendar-es.js'></script>";

        echo "<script type='text/javascript' src='".$Nivel."Scripts/funcionescalendario.js'></script>";

        echo "<script language='javascript'>var actual='$FechaActual';</script>";	

	   ?>

        <script src="<? echo $Nivel ?>bootstrap/js/bootstrap.min.js"></script>

        <link rel="stylesheet" type="text/css" href="<? echo $Nivel ?>Librerias/DataTables-1.10.4/media/css/jquery.dataTables.css">

        <script type="text/javascript" language="javascript" src="<? echo $Nivel ?>Librerias/DataTables-1.10.4/media/js/jquery.dataTables.js"></script>

        <link rel="stylesheet" type="text/css" href="<? echo $Nivel ?>Librerias/tagging/css/amsify.suggestags.css">

<!-- Amsify Plugin -->

<script type="text/javascript" src="<? echo $Nivel ?>Librerias/tagging/js/jquery.amsify.suggestags.js"></script>       

        <link rel="stylesheet" href="<? echo $Nivel ?>Librerias/multicombos/chosen.css">

				 <style type="text/css" media="all">

				     .chosen-rtl .chosen-drop { left: -9000px; }

					 .btn-file {

        position: relative;

        overflow: hidden;

    }

    .btn-file input[type=file] {

        position: absolute;

        top: 0;

        right: 0;

        min-width: 100%;

        min-height: 100%;

        font-size: 100px;

        text-align: right;

        filter: alpha(opacity=0);

        opacity: 0;

        outline: none;

        background: white;

        cursor: inherit;

        display: block;

    }

	#lightbox .modal-content {

    display: inline-block;

    text-align: center;   

}

#lightbox .close {

    opacity: 1;

    color: rgb(255, 255, 255);

    background-color: rgb(25, 25, 25);

    padding: 5px 8px;

    border-radius: 30px;

    border: 2px solid rgb(255, 255, 255);

    position: absolute;

    top: -15px;

    right: -55px;

    z-index:1032;

}



                  </style>

<SCRIPT language="JavaScript" type="text/JavaScript">



///////////////////////////////////////////////////funcion de insercion

function Guarda(){

 if(Formulario.Ciclo.value == '' || Formulario.Autor == '')

 alert('No hay usuario');

 else{

  Formulario.Accion.value='Guardar';

  Formulario.submit();

 }

}//Fin Guarda



function Elimina(){

 if(confirm("DESEA ELIMINAR EL REGISTRO?")){  

  Formulario.Accion.value='Eliminar';

  Formulario.submit();

 }

}//Fin Elimina



function Actualiza(){

if (Formulario.Ciclo.value == '' || Formulario.Autor == ''){

  alert("PROPORCIONE DATOS REQUERIDOS");

 } else {  

  Formulario.Accion.value='Actualizar';

  Formulario.submit();

 }

}//Fin Modifica

/////////////////////////////////////////////////fin



</script>

		<title>Crear Esquemas</title>

	</head>

    <body style="padding-top: 60px;">

<?

if (empty($IdEsquema))

$IdEsquema = 0;

$RowEsquema = $Conexion->MSelectRegistro("SELECT * from esquemas where IdEsquema = ".$IdEsquema);

include $Nivel."menu1.php";

echo '<br>';

?>



<div class="container">

<div class="panel panel-primary sombras">   

     <div class="titulo"><strong><i class="fa fa-music" aria-hidden="true"></i> Crear Esquema </strong></div>     

   <div class="row" style="margin-left: 10px; margin-right: 10px; margin-top:10px; margin-bottom:10px">

      <form class="form-horizontal" name="Formulario" method="Post" action="AccionEsquemas.php">

      <input name="Accion" id="Accion" type="hidden" value="">

      <div class="form-group">

      <div class="col-sm-12 col-md-6 ">

       <label for="Ciclo" class="col-md-3">Ciclo *</label>

	     <?php 

          if ($RowCan)

		 $Seleccionado = $RowEsquema["Ciclo"];		

		 $Vector =array("CICLO A" =>"A", "CICLO B"=>"B", "CICLO C"=>"C");

	     $Formulario->MSelectArray("Ciclo", $Vector,$Seleccionado, "","Elija el Ciclo Lit&uacute;rgico","form-control");  		 

		 ?>

      </div>              

      <div class="col-md-6 col-sm-12"> 

       <label for="Autor" class="col-md-2">Autor *</label>	

       <?php        

		$Formulario->MInputTexto("Autor",$RowEsquema["Autor"],40,45,4,'Placeholder = "Autor del Esquema"',"form-control"); 

		?>

      </div> 

       </div>      

       

       <div class="form-group">

        <div class="col-sm-12 col-md-6">    		

         <label for="TiempoLit" class="col-lg-6">Tiempo Lit&uacute;rgico *</label>

	     <?php 

		  if (!empty($RowEsquema["TiempoLit"])) 

		   $Seleccionado = $RowEsquema["TiempoLit"];      

		 $consulta = "SELECT tiempolit, idtiempo FROM tiemposlit order by idtiempo Desc"; 

		 $Formulario->ComboTabla("TiempoLit",$consulta,"tiempolit", "idtiempo", $Conexion->Link,$Seleccionado,1,"", "",1,"Sin Datos",20,''); 

		 ?>

        </div>

        <div class="col-md-6 col-sm-12"> 

       <label for="Celebracion" class="col-md-3">Celebraci&oacute;n *</label>	

       <?php        

		$Formulario->MInputTexto("Celebracion",$RowEsquema["Celebracion"],40,55,4,'Placeholder = "Celebraci&oacute;n"',"form-control"); 

		?>

      </div> 

       </div>

       

       <div class="form-group">

      <div class="col-sm-6 col-sm-12">    		

         <label for="Entrada" class="col-md-6">Entrada *</label>

	  <select data-placeholder="Elija cantos de entrada" name="Entrada[]" multiple class="chosen-select" tabindex="8">

            <option value=""></option>

              <? $seldir = "SELECT IdCanto, Titulo FROM cantos where UsoMisa = '1' order by Titulo Asc";

			$VarDire =$Conexion->MVectorRegistro($seldir);			

			while ($RenCan = mysqli_fetch_array($VarDire)){

			?>

            <option value=<? echo '"'.$RenDir["IdCanto"].'" '; if ($Entrada) {if (in_array($RenCan["IdCanto"], $Entrada)) echo " selected "; else "";} ?>><? echo $RenCan["Titulo"]; ?></option>            

            <? }?>

          </select>	  

        </div>        

        <div class="col-sm-6 col-sm-12">    		

         <label for="Ofertorio" class="col-md-4">Ofertorio *</label>

	  <select data-placeholder="Elija cantos de Ofertorio"  name="Ofertorio[]" multiple class="chosen-select" tabindex="8">

            <option value=""></option>

              <? $seldir = "SELECT IdCanto, Titulo FROM cantos where UsoMisa = '1' order by Titulo Asc";

			$VarDire =$Conexion->MVectorRegistro($seldir);			

			while ($RenCan = mysqli_fetch_array($VarDire)){

			?>

            <option value=<? echo '"'.$RenDir["IdCanto"].'" '; if ($Ofertorio) {if (in_array($RenCan["IdCanto"], $Ofertorio)) echo " selected "; else "";} ?>><? echo $RenCan["Titulo"]; ?></option>            

            <? }?>

          </select>	 

        </div>       

        </div>

        <div class="form-group">

          <div class="col-sm-6 col-sm-12">    		

         <label for="Comunion" class="col-md-4">Comuni&oacute;n *</label>

	  <select data-placeholder="Elija cantos de Comunion"  name="Comunion[]" multiple class="chosen-select" tabindex="8">

            <option value=""></option>

              <? $seldir = "SELECT IdCanto, Titulo FROM cantos where UsoMisa = '1' order by Titulo Asc";

			$VarDire =$Conexion->MVectorRegistro($seldir);			

			while ($RenCan = mysqli_fetch_array($VarDire)){

			?>

            <option value=<? echo '"'.$RenDir["IdCanto"].'" '; if ($Comunion) {if (in_array($RenCan["IdCanto"], $Comunion)) echo " selected "; else "";} ?>><? echo $RenCan["Titulo"]; ?></option>            

            <? }?>

          </select>	 

        </div>

         <div class="col-sm-6 col-sm-12">    		

         <label for="PostComunion" class="col-md-4">PostComuni&oacute;n </label>

	  <select data-placeholder="Elija cantos de PostComunion"  name="PostComunion[]" multiple class="chosen-select" tabindex="8">

            <option value=""></option>

              <? $seldir = "SELECT IdCanto, Titulo FROM cantos order by Titulo Asc";

			$VarDire =$Conexion->MVectorRegistro($seldir);			

			while ($RenCan = mysqli_fetch_array($VarDire)){

			?>

            <option value=<? echo '"'.$RenDir["IdCanto"].'" '; if ($PostComunion) {if (in_array($RenCan["IdCanto"], $PostComunion)) echo " selected "; else "";} ?>><? echo $RenCan["Titulo"]; ?></option>            

            <? }?>

          </select>	 

        </div>        

        </div>

        <div class="form-group">

         <div class="col-sm-6 col-sm-12">    		

         <label for="Salida" class="col-md-4">Salida </label>

	  <select data-placeholder="Elija cantos de Salida"  name="Salida[]" multiple class="chosen-select" tabindex="8">

            <option value=""></option>

              <? $seldir = "SELECT IdCanto, Titulo FROM cantos order by Titulo Asc";

			$VarDire =$Conexion->MVectorRegistro($seldir);			

			while ($RenCan = mysqli_fetch_array($VarDire)){

			?>

            <option value=<? echo '"'.$RenDir["IdCanto"].'" '; if ($Salida) {if (in_array($RenCan["IdCanto"], $Salida)) echo " selected "; else "";} ?>><? echo $RenCan["Titulo"]; ?></option>            

            <? }?>

          </select>	 

        </div>  

         <div class="col-sm-6 col-sm-12"> 

        <label for="Comentario" class="col-md-3" >Notas </label>				

         <?php        

		  $Formulario->MInputTexto("Comentario",$RowEsquema["Notas"],40,255,4,'Placeholder = "Comentario"',"form-control"); ?>

         </div>

        </div>

  <div class="form-group col-sm-12">          

        <p class="form-control-static" align="center">*Los campos marcados con asteriscos son obligatorios </p>        

      </div>

      <div class="col-sm-12">  

      <div class="col-sm-12 col-12 text-center" >

        <?php

	if ($IdEsquema){  

			$EventoM='Actualiza()';

			$EventoE='Elimina()';

			$Formulario->MBotonScript('Actualizar','Actualizar',$EventoM,"btn btn-primary btn3d", "glyphicon glyphicon-pencil");

			$Formulario->MBotonScript('Eliminar','Eliminar',$EventoE,"btn btn-danger btn3d","glyphicon glyphicon-remove");

			$Formulario->MLinkBoton("Esquemas.php", " Nuevo Canto","btn btn-success btn3d","fa fa-plus");

			//$Formulario->MLinkBoton("Videos.php?IdCanto=".$IdCanto, " Agregar Fuentes","btn btn-info btn3d","fa fa-youtube");

    }

    else{

		   $EventoG='Guarda()';

		   $Formulario->MBotonScript("Guardar",'Guardar',$EventoG,"btn btn-primary btn3d","fa fa-floppy-o");

			echo '<b>&nbsp;';

    }

		   ?>

      </div>

    </div>



  </form>

 </div>

</div>

<?

		//hacemos la consulta de los datos

		$consu = "select * from esquemas";

		$RowEsq=$Conexion->MVectorRegistro($consu);

		//Obtenemos el número de filas de la consulta

		$Numifilas = mysqli_num_rows($RowEsq);

		if ($Numifilas > 0){

			?>

            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="display" id="example">

	     <thead>

          <tr bgcolor="<?php echo $_CCT_GRID?>" style="cursor:pointer;color:#FFF"> 

            <td width="40%" height="25" align="center" ><strong><i class="fa fa-music" aria-hidden="true"></i> Ciclo</strong></td>

            <td width="20%" align="center"  bgcolor="<?php echo $_CCT_GRID?>"><strong><i class="fa fa-user-secret" aria-hidden="true"></i> Autor</strong></td>

            <td width="20%" align="center"  bgcolor="<?php echo $_CCT_GRID?>"><strong><i class="fa fa-comments" aria-hidden="true"></i> Tiempo</strong></td>

          </tr>

         </thead>

	<tbody>

            <?php

		while ($renglon = mysqli_fetch_array($RowEsq)){

		  echo '<tr>';

		  echo '<td>'.$renglon["Ciclo"].'</td>';	

		  echo '<td><a href="Esquemas.php?IdEsquema='.$renglon["IdEsquema"].'" title="Mostrar datos">'.$renglon["Autor"].'</td>';

		  echo '<td>'.$renglon["TiempoLit"].'</td>';

		  echo '</tr>';

		}

		?> 		

	</tbody>

	<tfoot>

		<tr>

			<td></td>

            <td></td>

			<td width="0%"></td>

		</tr>

	</tfoot>

</table>

<?php

}else

		   echo '<p class="bg-warning" align="center">No existen datos</p>';

?>	 

</div>

</div>

<div class="spacer"></div>



<script src="<? echo $Nivel?>Librerias/multicombos/docsupport/prism.js" type="text/javascript" charset="utf-8"></script>        

<script src="<? echo $Nivel?>Librerias/multicombos/chosen.jquery.js" type="text/javascript"></script>

<? 

    //llamamos a las funciones para las animaciones

	echo "<script type='text/javascript'>";

	echo "var config = {

      '.chosen-select'           : {},

      '.chosen-select-deselect'  : {allow_single_deselect:true},

      '.chosen-select-no-single' : {disable_search_threshold:10},

      '.chosen-select-no-results': {no_results_text:'?Sin resultados!'},

      '.chosen-select-width'     : {width:'100%'}

    }

	for (var selector in config) {

      $(selector).chosen({ width: '100%' });	  

    }";

	echo '</script>';



	?>   



<script type="text/javascript" language="javascript" src="<?php echo $Nivel ?>Librerias/DataTables-1.10.4/media/js/jquery.dataTables.js"></script>    

<script type="text/javascript" language="javascript" class="init">

$(document).ready(function() {

	$('#example').dataTable( {

        "pagingType": "simple_numbers"

    } );	

} );

</script>