<?php
  //Query parametros perfil
$queryperfil = mysqli_query($mysqli, "SELECT * FROM perfil")
                                or die('error'.mysqli_error($mysqli));
$rows  = mysqli_num_rows($queryperfil);
$data_perfil  = mysqli_fetch_assoc($queryperfil);
$folio_perfil = $data_perfil['folio'];
$folio_rem_perfil = $data_perfil['folio2'];
$nombre_perfil = $data_perfil['nombre_empresa'];
$direccion_perfil = $data_perfil['direccion'];
$direccion_perfil = $data_perfil['direccion'];
$email_perfil = $data_perfil['email'];
$almacen_perfil = $data_perfil['almacen'];
$almacenista_perfil = $data_perfil['almacenista'];
  
  
?>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
	<!-- El CSS de DataTables -->
	<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/jszip-2.5.0/pdfmake-0.1.18/dt-1.10.12/af-2.1.2/b-1.2.2/b-colvis-1.2.2/b-flash-1.2.2/b-html5-1.2.2/b-print-1.2.2/cr-1.3.2/fc-3.2.2/fh-3.1.2/kt-2.1.3/r-2.1.0/rr-1.1.2/sc-1.4.2/se-1.2.0/datatables.min.css"/>
	<!-- El CSS de Bootstrap -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
	<!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">-->
</head>


<section class="content-header">
  <h1>
    <i class="fa fa-folder-o icon-title"></i> Motivos para saldo inicial para el almacen <?php echo $almacen_perfil ?>;

    <!--<a class="btn btn-primary btn-social pull-right" href="?module=form_motivos_si&form=add" title="agregar" data-toggle="tooltip">
      <i class="fa fa-plus"></i> Agregar
    </a>-->
  </h1>

</section>


<section class="content">
  <div class="row">
    <div class="col-md-12">

    <?php 
    $queryclose = mysqli_query($mysqli, "SELECT apertura FROM apertura_cierre where id = 1") 
or die('error: '.mysqli_error($mysqli));
$rows  = mysqli_num_rows($queryclose);
$data  = mysqli_fetch_assoc($queryclose);
$bandera = $data['apertura'];
/*print_r($bandera);
die();*/

/*if($bandera == 'CERRADO') {
	echo '<script>
                alert("EL ALMACEN SE ENCUENTRA CERRADO POR INVENTARIO DEL SUPERVISOR");
                window.location = "https://almacencdmxve.casatequilaarandas.com/main.php?module=closed";
          </script>';     
    return;
}*/

if ($bandera == 'CERRADO') {
    echo '<script>
                alert("EL ALMACEN SE ENCUENTRA CERRADO POR INVENTARIO DEL SUPERVISOR");
                // Obtener el nombre del servidor y construir la URL base
                var serverUrl = "http://" + window.location.hostname;
                var url = serverUrl + "/main.php?module=closed";
                window.location = url;
          </script>';
    return;
}

    if (empty($_GET['alert'])) {
      echo "";
    } 
  
    elseif ($_GET['alert'] == 1) {
      echo "<div class='alert alert-success alert-dismissable'>
              <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
              <h4>  <i class='icon fa fa-check-circle'></i> Exito!</h4>
             Nuevos dato almacenado correctamente.
            </div>";
    }

    elseif ($_GET['alert'] == 2) {
      echo "<div class='alert alert-success alert-dismissable'>
              <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
              <h4>  <i class='icon fa fa-check-circle'></i> Exito!</h4>
             Datos modificados correcamente.
            </div>";
    }

    elseif ($_GET['alert'] == 3) {
      echo "<div class='alert alert-success alert-dismissable'>
              <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button>
              <h4>  <i class='icon fa fa-check-circle'></i> Exito!</h4>
            Se eliminaron los datos correctamente
            </div>";
    }
    ?>

      <div class="box box-primary">
        <div class="box-body">
         <div class="table-responsive"> 
          <table id="dataTables1" class="table table-bordered table-striped table-hover">
      
            <thead>
              <tr>
                <th class="center">No.</th>
                <th class="center">id</th>
                <th class="center">Nombre</th>
				 <th class="center">Tipo</th>
            
				
                <th></th>
              </tr>
            </thead>
            <tbody>
            <?php  
            $no = 1;
            $query = mysqli_query($mysqli, "SELECT id,nombre,tipo FROM motivo where id = '1' ORDER BY id asc")
                                            or die('error: '.mysqli_error($mysqli));

            while ($data = mysqli_fetch_assoc($query)) { 
             # $precio_compra = format_rupiah($data['precio_compra']);
             # $precio_venta = format_rupiah($data['precio_venta']);
           
              echo "<tr>
                      <td width='30' class='center'>$no</td>
                      <td width='80' class='center'>$data[id]</td>
                      <td width='180'>$data[nombre]</td>
					  <td width='180'>$data[tipo]</td>
                                    
                    
                      <td class='center' width='80'>
                        <div>
                          <!-- <a data-toggle='tooltip' data-placement='top' title='modificar' style='margin-right:5px' class='btn btn-primary btn-sm' href='?module=form_motivos_si&form=edit&id=$data[id]'>
                              <i style='color:#fff' class='glyphicon glyphicon-edit'></i>
                          </a> -->"; 
            ?>
                         <!-- <a data-toggle="tooltip" data-placement="top" title="Eliminar" class="btn btn-danger btn-sm" href="modules/trade/catalogos/motivos_si/proses.php?act=delete&id=<?php echo $data['id'];?>" onclick="return confirm('estas seguro de eliminar<?php echo $data['nombre']; ?> ?');">
                              <i style="color:#fff" class="glyphicon glyphicon-trash"></i>
                          </a>-->
        </form>
		
      </div><!-- /.box -->						  
                          </a>						  
            <?php
              echo "    </div>
                      </td>
                    </tr>";
              $no++;
            }
            ?>
            </tbody>
          </table>
		  
	
</section><!-- /.content-->
<script language="javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
	<!-- El JavaScript de DataTables -->
	<script language="javascript" type="text/javascript" src="https://cdn.datatables.net/v/dt/jszip-2.5.0/pdfmake-0.1.18/dt-1.10.12/af-2.1.2/b-1.2.2/b-colvis-1.2.2/b-flash-1.2.2/b-html5-1.2.2/b-print-1.2.2/cr-1.3.2/fc-3.2.2/fh-3.1.2/kt-2.1.3/r-2.1.0/rr-1.1.2/sc-1.4.2/se-1.2.0/datatables.min.js"></script>
	<!-- El JavaScript de BootStrap -->
	<script language="javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script type="text/javascript">
$('#dataTables2').dataTable( 

  
{
	
    "drawCallback": function( settings ) {
         $('ul.pagination').addClass("pagination-sm");
		 
    }
	
	
});
	</script>

<script >
$('#dataTables2').dataTable( 

  
{
	
    "drawCallback": function( settings ) {
         $('ul.pagination').addClass("pagination-sm");
		 
    }
	
	
});
	</script>