<?php
session_start();
define('Admin_USER',true);
if(!isset($_SESSION['adm1n']) || $_SESSION['adm1n']['Nbr'] == ''){
  
       header("Location: ../misc/default.php");
       exit;
       
}
require_once("../../includes/php/defines.php");
require_once("../../includes/php/classes/mainClass.php");
require_once("../../includes/php/classes/galleryClass.php");

$pic = new galleryClass();
if(isset($_GET['Id']) && $_GET['Id'] != ''){

    $albumInfo = $pic->getAlbumInfo($_GET['Id']);

}else{

    $albumInfo = array();

}
$categories = $pic->getAlbumCategories();
$albums = $pic->getAlbums($albumInfo['Category']);

?>
<section>
	<div class="container-fluid">
		<div class="container">
			<div class="col-md-12 result-heading">
				<div class="rh-form">
                <?php
                if(isset($_GET['ReturnPage']) && $_GET['ReturnPage'] != ''){                                        

                    echo '<form>';
                    echo '<div class="form-group">';
                    echo '<div class="return-div"><span onclick="contentChanger(\''.$_GET['ReturnPage'].'\');"><< RETURN TO GALLERY MANAGER</span></div>';
                    echo '</div>';       
                    echo '</form>';  

                }             
                ?>
					<h1>Add Photos To Photo Gallery</h1>
					
					<form class="a-r-form" id="Admin_Form">
                            <div id="Animation">
                                <div class="blockG" id="rotateG_01"></div>
                                <div class="blockG" id="rotateG_02"></div>
                                <div class="blockG" id="rotateG_03"></div>
                                <div class="blockG" id="rotateG_04"></div>
                                <div class="blockG" id="rotateG_05"></div>
                                <div class="blockG" id="rotateG_06"></div>
                                <div class="blockG" id="rotateG_07"></div>
                                <div class="blockG" id="rotateG_08"></div>                                            
                            </div>
                            <div id="Result"></div>                         												
                        <div class="form-group">
                            <label>Album Category</label>
                            <select  class="col-md-12" id="Category" name="Category" onchange="updateAlbums();">
                            <option value="">Choose Album Category</option>
                            <?php
                                for($i=0;$i<count($categories);$i++){

                                    if($categories[$i]['Name'] != ''){

                                        echo '<option value="'.$categories[$i]['Nbr'].'"';
                                        if($albumInfo['Category'] == $categories[$i]['Nbr']){

                                            echo 'selected="selected"';

                                        }
                                        echo '>'.$categories[$i]['Name'].'</option>';

                                    }

                                }
                            ?>
                            </select>
                            </div>  
                            <div class="form-group" id="Album-Menu" name="Album-Menu">                    
							<select  class="col-md-12" id="Album" name="Album" onchange="galleryAlbum();" <?php if(!isset($albumInfo['Category']) || $albumInfo['Category'] == ''){ echo 'disabled="disabled"'; } ?> >
                                <option value="">Choose Album</option>
                                    <?php
                                    for($i=0;$i<count($albums);$i++){
                                        
                                        if($albums[$i]['Name'] != ''){
                                        
                                            echo '<option value="'.$albums[$i]['Nbr'].'"';
                                            if(isset($_GET['Id']) && $_GET['Id'] == $albums[$i]['Nbr']){
                                                
                                                echo ' selected="selected"';
                                                
                                            }    
                                            echo '>'.$albums[$i]['Name'].'</option>';
                                            
                                        }
                                        
                                    }
                                    ?>
							</select>
						</div>
                          <div class="form-group" id="AlbumName" name="AlbumName" style="display:none;">
							<label>Album Name</label>
							<input type="text" class="col-md-12" id="Album_Name" name="Album_Name">
						</div>
						<div class="form-group">
                        <p class="label-p">Photo Description</p>
							<textarea class="col-md-12" rows="4" id="Desc" name="Desc"></textarea>
						</div>
						<div class="form-group dropzone" id="DropZone" name="DropZone" style="background-color:#e6e6e6; border:dashed 1px #ccc; border-radius:10px; text-align:center;">														
							<label><strong>Images</strong></label>
							<input type="file" name="Image[]" id="Image[]" multiple class="inputFile">						
						</div>							
						<div id="PreviewContainer" name="PreviewContainer" class="dropzone-previews"></div>
						<div class="form-group" id="Submit_Paragraph">
                            <input type="hidden" id="Option" name="Option" value="Add-Photos"/>
							<input type="hidden" id="Clear" name="Clear" value=""/>
							<input type="button" value="submit" onclick="processImage('Add-Photos','Admin_Form');">
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</section>
<script type="text/javascript" src="js/dropzone.js"/>
<script type="text/javascript" src="includes/ajax/dropzone_gallery_processor.js"/>
<script>
addEventListener("keyup", function(event) {
    if (event.keyCode === 13) {
        event.preventDefault();
        processForm('Add-Photos','Admin_Form');
    }
});
</script>
