<?php

$galeriasDao = new \Dao\Galerias();

$galeriasDao->getGaleriaPorId($conecta, base64_decode(filter_input(INPUT_GET, 'id')));

?>

<div class="breadcrumb-holder">

    <div class="container-fluid">

        <ul class="breadcrumb">

            <li class="breadcrumb-item"><a href="./">Home</a></li>

            <li class="breadcrumb-item"><a href="galerias.php">Galerias</a></li>

            <li class="breadcrumb-item active"><?php echo ($galeriasDao->id == 0 ? 'Adicionar Galeria' : 'Editar Galeria'); ?></li>

        </ul><!--/.breadcrumb -->

    </div><!---/.container-fluid -->

</div><!--/.breadcrumb-holder -->

<section class="dashboard-counts section-padding">

    <div class="container-fluid">

        <div class="row">

            <div class="col-lg-12">

                <div class="card">

                    <div class="card-header d-flex align-items-center">

                        <h2 class="h5 display"><?php echo ($galeriasDao->id == 0 ? 'Adicionar Galeria' : 'Editar - ' . $galeriasDao->nome); ?></h2>

                    </div><!--/.card-header -->

                    <div class="card-body">

                        <form class="form-horizontal" method="post" action="?p=salvar" enctype="multipart/form-data">

                            <input type="hidden" name="id" id="id" value="<?php echo $galeriasDao->id; ?>">

                            <div class="form-group row">

                                <label class="col-sm-2 form-label">Nome</label>

                                <div class="col-sm-7">

                                    <input type="text" name="nome" id="nome" placeholder="Nome" value="<?php echo $galeriasDao->nome; ?>" maxlength="90" class="form-control" required autofocus>

                                </div><!--/.col-sm-7 -->

                            </div><!--/.form-group -->

                            <div class="form-group row">
                                <label class="col-sm-2 form-label">Descrição</label>
                                <div class="col-sm-10">
                                    <textarea cols="13" rows="5" id="descricao" name="descricao" class="editor_textarea"><?php echo stripslashes($galeriasDao->descricao); ?></textarea>
                                </div><!--/.col-sm-10 -->
                            </div><!--/.form-group -->

                            <div class="form-group row" style="display: none">

                                <label class="col-sm-2 form-label">Logo</label>

                                <div class="col-sm-4">

                                    <input type="file" name="logo" id="logo" class="file-input" onchange="readImageForCrop('imagem', 'logo', NaN);">

                                </div><!--/.col-sm-4 -->

                                <label class="col-sm-2 form-label">Imagem</label>

                                <div class="col-sm-4">

                                    <input type="file" name="image" id="image" class="file-input">

                                </div><!--/.col-sm-4 -->

                            </div><!--/.form-group -->

                            <div class="form-group cropper row <?php echo ($galeriasDao->id == 0) ? 'hidden-croper' : ''; ?>">

                                <label class="col-sm-2 form-label"></label>

                                <div class="col-sm-12">

                                    <div class="img-container">

                                        <?php

                                        if ($galeriasDao->logo != '' && file_exists($pasta . $galeriasDao->logo))

                                            echo '<img id="imagem" src="' . $pasta . $galeriasDao->logo . '" class="height200" alt="">';

                                        else

                                            echo '<img id="imagem" src="https://placehold.it/300x300" class="height200" alt="">';

                                        ?>

                                    </div><!--/.img-container -->

                                    <label class="col-sm-2 form-label"></label>

                                    <div class="docs-preview clearfix col-sm-9 hidden-croper">

                                        <div class="img-preview preview-lg"></div>

                                        <div class="img-preview preview-md"></div>

                                        <div class="img-preview preview-sm"></div>

                                        <div class="img-preview preview-xs"></div>

                                    </div>

                                    <input type="hidden" class="form-control" name="dataX" id="dataX" placeholder="x">

                                    <input type="hidden" class="form-control" name="dataY" id="dataY" placeholder="y">

                                    <input type="hidden" class="form-control" name="dataWidth" id="dataWidth" placeholder="width">

                                    <input type="hidden" class="form-control" name="dataHeight" id="dataHeight" placeholder="height">

                                </div><!--/.col-sm-12 -->

                            </div><!--/.cropper -->

                            <div class="form-group row">

                                <label class="col-sm-2"></label>

                                <div class="col-sm-2">

                                    <button class="btn btn-sm btn-primary">

                                        <i class="fa fa-database"></i> Salvar

                                    </button>

                                </div>

                            </div><!--/.form-group -->

                        </form>

                    </div><!--/.card-body -->

                </div><!--/.card -->

            </div><!--/.col-lg-12 -->

        </div><!--/.row -->

    </div><!--/.container-fluid -->

</section><!--/.dashboard-counts -->