<?php
error_reporting(0);
ini_set("display_errors", 0 );
header('Content-Type: text/html; charset=utf-8');
include("../configuracao.php");//confirma no banco de dados
include("../inclusos/funcoes.php");
include("../seguranca.php"); // Inclui o arquivo com o sistema de seguran?a
protegePagina(); // Protege a página

?>
<!doctype html>
<html ng-app="myApp">
<head>
<title>MAX LAYOUTS</title>

<link rel="stylesheet" href="inclusos/styles.css">
<link href="inclusos/css_precopratico.css" rel="stylesheet" type="text/css">        
<meta charset="utf-8">
</head>
<body>
<?php
//RECEBE DADOS

$idobra = $_POST['idobra'];
$album_name = $_POST['album_name'];


//Dados da Tabela
$tabela                 ="albuns";

$campos_tabela = "idobra, album_name, idusuario, idfilial";

$campos_value = "'$idobra', '$album_name', '".$_SESSION['usuarioID']."', '".$_SESSION['idfilial_usuario']."'";

//INSERIR REGISTROS
if($_POST['acao'] == "AddAlbum"){
	$salvar = Salvar($tabela,  $campos_tabela, $campos_value);

// RETORNA ULTIMO ID INSERIDO
	$id_insert = mysql_insert_id();
	$redireciona = VerificaSqlSemAlert($salvar, "listar_albuns_obra.php?idobra=".$idobra."", "listar_albuns_obra.php?idobra=".$idobra."");
}

if($_GET['Excluir'] == "Sim"){
$album_id = $_GET['album_id'];
$DeletaColaborador = mysql_query("DELETE FROM albuns WHERE album_id='$album_id'", $conexao) or die(mysql_error());
$DeletaColaborador = mysql_query("DELETE FROM fotos WHERE foto_album='$album_id'", $conexao) or die(mysql_error());
$redireciona = VerificaSqlSemAlert($DeletaColaborador, "listar_albuns_obra.php?idagenda=".$idobra."", "listar_albuns_obra.php?idagenda=".$idobra."");	
}

?>
<style type="text/css">
<!--
.style1 {font-weight: bold}
-->
</style>
<script type="text/javascript">
function EnviarFormulario()
{
    document.forms["cadastro"].submit();
}
</script>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="189" height="40" align="center" bgcolor="#D9D9D9" class="TituloPagina" style="padding-left: 5px; cursor:pointer">ÁLBUNS</td>
        <td align="right">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
       <form name="cadastro" id="cadastro" method="post" action="listar_albuns_obra.php" enctype="multipart/form-data">
      <input type="hidden" name="acao" value="AddAlbum">
      <input type="hidden" name="idobra" value="<?php echo $_GET['idobra'];?>"> 
    <td colspan="2"><table width="100%" border="0" align="center" cellpadding="6" cellspacing="0">
        <tr>
          <td align="center" valign="middle" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="7">
            <tr>
              <td width="3276850%" colspan="2" align="left"><strong style="color: #676767;  font-size: 12px;">NOME DO ALBUM</strong></td>
            </tr>
            <tr>
              <td colspan="2" style="color: #676767; font-size: 12px;"><input name="album_name" type="text" required class="form-campos" id="album_name"  style="width:100%;  font-weight: bold"  /></td>
            </tr>
            </table></td>
        </tr>
        <tr>
          <td align="center" valign="middle" bgcolor="#FFFFFF"><input name="button5" type="submit" class="BoxVerde" id="button4" value="Criar Album" style="width: 100px; height: 35px;" ></td>
        </tr>
        <tr>
          <td width="50%" align="center" valign="middle" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0" cellpadding="4">
            <tr>
              <td valign="top" bgcolor="#FFFFFF"><!-- INICIO DIV --><!-- FIM DIV --></td>
            </tr>
            </table>
            <table width="100%" border="0" align="center" cellpadding="3" cellspacing="2">
              <tr class="TextoCinzaEscuro">
                <td width="70%" height="30" bgcolor="#A6A6A6" class="TextoCinzaEscuro"><strong>TITULO ALBUM</strong></td>
                <td align="center" bgcolor="#A6A6A6"><strong>VER</strong></td>
                <td align="center" bgcolor="#A6A6A6"><strong>ADICIONAR</strong></td>
              </tr>
              <?php
			$cor_fundo = "#FFFFFF";	
			if($data == ""){
				$data = $_GET['data_atual'];
			}
			 	$seleciona = Seleciona("albuns", "WHERE idobra='".$_GET['idobra']."'", "");
			while($linha=mysql_fetch_array($seleciona)){					
			
			if($cor_fundo == "#FFFFFF"){
				$cor_fundo = "#E4E4E4";
			}else{
				$cor_fundo = "#FFFFFF";
			}
		?>
              <tr class="TextoCinzaPequeno" bgcolor="<?php echo $cor_fundo;?>">
                <td height="30"><?php echo $linha['album_name'];?></td>
                <td align="center"><a href="listar_albuns_obra_detalhe.php?idalbum=<?php echo $linha['album_id'];?>&nome_album=<?php echo $linha['album_name'];?>" target="_self">VER FOTOS</a></td>
                <td align="center"><a href="http://grupomax.minhaempresa.online/albumdefotos/admin/album.php?edit=<?php echo $linha['album_id'];?>" target="_self">ADICIONAR FOTOS</a></td>
              </tr>
              <?php }?>
            </table></td>
        </tr>
        </table></td>
            </form>
  </tr>
</table>
</body>
</html>