<?php
$pageTitle = 'Zip upload';
require_once('common/header.php');

if(!empty($_POST)){
		$zip = new ZipUpload();
		if($zip->upload()){
				redirect_to('list.php?table=cmsgen_gallerypictures');
		}
}

$table = new Table('cmsgen_galleries');
$allGalleries = $table->findAll();
?>

<form action="" method="post" enctype="multipart/form-data" id="ZipUpload">
    <h1 class="title">Zip Upload</h1>
    <div class="form round drop_shadow" id="list">
        <table cellpadding="4" width="100%" style="font-size:12px;">
        <?php if(isset($zip)) : ?>
        <tr>
            <td><?php print_r($zip); ?></td>
        </tr>
        <?php endif; ?>
            <tr>
                <td><h2>Gallery</h2></td>
                <td>
                    <select name="gallery_id">
                    <option value="">Select Gallery Name</option>
                    <?php foreach($allGalleries as $gallery) : ?>
                        <option value="<?php echo $gallery['id']; ?>"><?php echo $gallery['name']; ?></option>
                    <?php endforeach; ?>
                    </select>&nbsp;<a href="<?php echo pageLink('generate.php?table=cmsgen_galleries'); ?>">Add a new entry</a>
                </td>
            </tr>

            <tr>
                <td><h2>Zip file</h2></td>
                <td><input type="file" name="zip" /></td>
            </tr>


        </table>
        <div class="clear"></div>
        <br />
        <input type="submit" name="submit_file" class="submit round drop_shadow" value="Save" style="float:left;margin-left:4px;" /><br><br><br><br>
        <a href="<?php echo pageLink('list.php?table=cmsgen_gallerypictures'); ?>">List all records</a>
        <div class="clear"></div>
    </div>

</form>

<?php require_once('common/footer.php'); ?>