<?

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

$Nivel=$_Nivel2;

$ObjSesion=new Sesiones();  

$ObjSesion->MVerifica($Nivel);

$Conexion=new DBAccess();

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

$Formulario=new Formulario();

//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++;	

}

?>

<!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=ISO-8859-1">

		<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>

        <script type="text/javascript" src="<? echo $Nivel ?>Librerias/tinymce/tinymce.min.js"></script>

         <script type="text/javascript">

           tinymce.init({

            selector: "textarea",

			language : 'es_MX',

			 forced_root_block : "", 

			  plugins: [

      'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker',

      'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',

      'save table contextmenu directionality emoticons template paste textcolor'

    ],

             force_br_newlines : true,

             force_p_newlines : false,

			 schema: 'html5'

           });

         </script>

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

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

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

                  </style>

                   <style>

               #mdialTamanio{

                 width: 60% !important;

                   }					 

             </style>             

		<title>Cat&aacute;logo de Cantos</title>        

	</head>

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

<?

$IdCanto = $_GET["IdCanto"];

//echo "-> ".$IdCanto;

if (empty($IdCanto))

$IdCanto = 0;

include $Nivel."menu1.php";  

//echo "SELECT * FROM TRABSOCIAL WHERE IDTRABSOC=".$IdLocalidad;

//echo "->".$IdMunicipio;

$RowCan=$Conexion->MSelectRegistro("Select * from cantos where IdCanto=".$IdCanto);



?>

<div class="container">

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

     <div class="titulo"><strong><i class="fa fa-music" aria-hidden="true"></i> Cat&aacute;logo de Cantos </strong></div>

     

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

  <form id="Formulario" name="Formulario" method="Post" action="AccionCantos.php">    

    <input name="IdCanto" type="hidden" id="IdCanto" value="<?php echo $IdCanto?>" />

  

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

 

      <div class="form-group col-md-4">    

		<label for="Titulo" class="col-lg-4 control-label" >T&iacute;tulo *</label>				

         <?php        

		$Formulario->MInputTexto("Titulo",$RowCan["Titulo"],40,45,4,'Placeholder = "Nombre del canto"',"form-control"); ?>

      </div>     

         <div class="form-group col-md-4"> 

       <label for="Apellidos" class="col-lg-6 control-label">Autor Letra *</label>	

        <?php  

		 if (!empty($RowCan["IdAutorLetra"])) 

		   $Seleccionado = $RowCan["IdAutorLetra"];

		 $consulta = "SELECT concat(Nombres,' ',Apellidos) As Autor, IdAutor FROM autores order by IdAutor Desc"; 

		 $Formulario->ComboTabla("IdAutorLetra",$consulta,"Autor", "IdAutor", $Conexion->Link,$Seleccionado,1,"", "",1,"Sin Datos",20,''); ?>

        </div>

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

         <label for="CodPos" class="col-lg-6 control-label">Autor M&uacute;sica *</label>

	     <?php  

		  if (!empty($RowCan["IdAutorMusica"])) 

		   $Seleccionado = $RowCan["IdAutorMusica"];     

		 $consulta = "SELECT concat(Nombres,' ',Apellidos) As Autor, IdAutor FROM autores order by IdAutor Desc"; 

		 $Formulario->ComboTabla("IdAutorMusica",$consulta,"Autor", "IdAutor", $Conexion->Link,$Seleccionado,1,"", "",1,"Sin Datos",20,''); 

		 ?>

        </div>

         <div class="form-group col-md-4">    

		<label for="Titulo" class="col-lg-8 control-label" >Disco </label>				

         <?php        

		$Formulario->MInputTexto("Disco",$RowCan["Disco"],40,35,4,'Placeholder = "Album o disco"',"form-control"); ?>

      </div>  

      <div class="form-group col-md-4">    

		<label for="Titulo" class="col-lg-12 control-label" >A&ntilde;o *</label>				

         <?php        

		$Formulario->MInputTexto("Anio",$RowCan["Anio"],40,35,4,'Placeholder = "A&ntilde;o de publicaci&oacute;n"',"form-control"); ?>

      </div>     

      <!-- <div class="row"> -->

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

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

	     <?php 

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

		   $Seleccionado = $RowCan["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="form-group col-sm-12">    		

         <h5><strong>Etiquetas * (escriba y pulse enter)</strong></h5>

         <div class="form-group">

	     <?php       

		$Formulario->MInputTexto("Etiquetas",$RowCan["Etiquetas"],50,50,4,'Placeholder = ""',"form-control");

		 ?>

         </div>

        </div>

      <!--   </div> -->

       <div class="form-group col-md-4">   

       <?php

          // si esta vacia asigna 'si' sino asigna el valor de la base

          $variable = empty($RowCan["UsoMisa"]) ? '0' : $RowCan["UsoMisa"];

	   ?>        

          <label class="col-lg-6 form-check-label" for="exampleCheck1">&iquest;Es para Misa?</label>

         <input type="checkbox" class="form-check-input" id="UsoMisa" value="<?=$variable?>" <?php if (($RowCan["UsoMisa"]) || (!$RowCan["UsoMisa"])) echo ' checked '?> >

      </div> 

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

       <label for="Momento" class="col-lg-6 control-label">Momento de uso</label>

	     <?php 

		  if (!empty($RowCan["Momento"])) 

		   $Seleccionado = $RowCan["Momento"];      

		 $consulta = "SELECT IdMomento, Momento FROM momentos order by IdMomento Desc"; 

		 $Formulario->ComboTabla("Momento",$consulta,"Momento", "IdMomento", $Conexion->Link,$Seleccionado,1,"", '',1,"Sin Datos",20,''); 

		 ?>

      </div>

     <!-- <div class="form-group col-sm-6">

       <label for="Momento" class="col-lg-6 control-label">Ciclo</label>

	     <?php /*

          if ($RowCan)

		 $Seleccionado = $RowCan["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="form-group col-sm-12">

         <label for="Acordes" class="col-lg-12 control-label">Acordes </label>

         <? 

		$Formulario->MTextArea("Acordes",6,25,$RowCan["Acordes"],'Placeholder = "Letra y acordes"',"form-control"); ?>

        </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 ($IdCanto){  

			$EventoM='Actualiza()';

			$EventoE='Elimina()';

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

			//echo '&nbsp;';

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

			//echo '<b>&nbsp;';  

			//echo '<a href="Localidades.php" class="btn btn-success"><i class="fa fa-plus" aria-hidden="true"></i> NUEVA LOCALIDAD</a>&nbsp;';

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

			//echo '<b>&nbsp;';

			$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 cantos.Titulo, cantos.IdCanto, concat(autores.Nombres, ' ' ,autores.Apellidos) As Autor, cantos.IdAutorMusica,

cantos.Disco, cantos.Anio FROM cantos LEFT JOIN autores ON cantos.IdAutorMusica = autores.IdAutor";

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

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

		$Numifilas = mysqli_num_rows($RowCant);

		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> Titulo</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>

          </tr>

         </thead>

	<tbody>

            <?php

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

		  echo '<tr>';	

		  echo '<td><a href="CatCantos.php?IdCanto='.$renglon["IdCanto"].'" title="Mostrar datos">'.$renglon["Titulo"].'</td>';

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

		  echo '</tr>';

		}

		?> 		

	</tbody>

	<tfoot>

		<tr>

			<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 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"

    } );

	

} );



$("#UsoMisa").on('change', function() {

    if( $(this).is(':checked') ) {

      $("#Momento").prop('disabled', false).trigger("chosen:updated");

    } else {

        $("#Momento").prop('disabled', 'disabled').trigger("chosen:updated");

    }

});







</script> 

<script type="text/javascript">

	$('input[name="Etiquetas"]').amsifySuggestags({

		type : 'amsify'

	});

	

</script>

<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 language="JavaScript" type="text/JavaScript">

function Elimina(){

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

  Formulario.Accion.value='Eliminar';

  Formulario.submit();

 }

}//Fin Elimina



function Actualiza(){

if (Formulario.Titulo.value=='' || Formulario.TiempoLit.value==''){

  alert("PROPORCIONE DATOS REQUERIDOS");

 } else {  

  Formulario.Accion.value='Actualizar';

  Formulario.submit();

 }

}//Fin Modifica

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



///////////////////////////////////////////////////funcion de inserción

function Guarda(){

if (Formulario.Titulo.value=='' || Formulario.TiempoLit.value==''){

  alert("Complete los campos requeridos");

 } else {

  Formulario.Accion.value='Guardar';

  Formulario.submit();

 }

}//Fin Guarda



function validateEnter(e) {

	var key=e.keyCode || e.which;

	if (key==13){ return true; } else { return false; }

}

</script> 

