<?php
session_start();
require_once('../conexion.php');
require_once('../include/sesiones.php');
$suc_id=limpiar($_GET['id']);
if ($suc_id==$sucursal) 
    {
    echo '<div class="alert alert-danger alert-dismissable">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            <strong>Error! </strong>  No se puede Eliminar.
         </div>';
    }
else
    {  
    $suc=mysqli_query($con,"SELECT * FROM articulos_has_bodegas where sucursal='$suc_id' AND  empresa='$empresa'") or  die(mysqli_error($con));
    $results=mysqli_fetch_array($suc);
    $numrows = $results['sucursal'];
    if($numrows > 0) 
        {
    	 echo '<div class="alert alert-danger alert-dismissable">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                <strong>Error! </strong>  No se puede Eliminar.
               </div>';
        }
    else
        {
            $registros=mysqli_query($con,"DELETE FROM bodegas where sucursal='$suc_id' and empresa='$empresa'") or die(mysqli_error($con));
            $registros=mysqli_query($con,"DELETE FROM sucursal where suc_id='$suc_id' and empresa='$empresa'") or die(mysqli_error($con));
             
            echo '<div class="alert alert-danger alert-dismissable">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
            <strong>Sucursal!</strong> Eliminada correctamente.
            </div>';
        }
    }
?>