<?php
//if (isset($_GET['i4'])) {
//    $idnya = $_GET['i4'];
//} else {
//    $idnya = "";
//    echo "<script>  
//             document.location.href='./?p463=4f4adcbf8c6f66dcfc8a3282ac2bf10aOOO';
//         </script>";
//};

$cekid = new cekID();
$cekid->Cek('sekolah', 'id', $id_page);


$user_admin = new crudData();
$editUser = $user_admin->editData('sekolah', 'id', $id_page);
$data = $editUser->fetch(PDO::FETCH_OBJ);

?>
<style>
    .fontInput {
        font-size: 12px;
        font-family: arial;
    }

    .judul {
        font-size: 15px;
        font-family: arial;
    }
</style>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <?php require('./layout/headerpage.php'); ?>

    <div class="container col-12 mb-4 pb-5">
        <div class="row">
            <div class="col-md-12">
                <div class="col-12">
                    <div class="card  mx-3">
                        <div class="timeline-header bg-primary  py-1 pl-1">
                            <b class="text-light judul"><span class="bi bi-house"></span> Profil Lembaga</b>
                        </div>
                        <div class="row col-12">
                            <div class="col-12">
                                <div class="card-body mt-4 px-1 mx-2">

                                    <div class="row">
                                        <div class="col-12 col-sm-12 col-md-12">
                                            <div class="info-box mb-3">
                                                <div class="info-box-content">

                                                    <div class="relative mb-2 pb-4">
                                                        <input name="judul" value="SETING LEMBAGA" style="background-color: gainsboro;" class="form-control-sm col-sm-3 col-lg-1 fontInput small bg-default mt-3 text-center" disabled>
                                                    </div>

                                                    <div class="col-sm-12 invoice-col pt-0">
                                                        <form action="" method="post">
                                                            <?php $csrf->token(); ?>
                                                            <div class="row mx-2 mt-3">
                                                                <div class="col-md-12">
                                                                    <div class="card-body mt-2 px-0 mx-0">
                                                                        <div class="row">
                                                                            <label for="exampleEmail" class="col-lg-4 col-md-5 col-sm-12 col-form-label">Nama </label>
                                                                            <div class="col-lg-8 col-md-7 col-sm-12">
                                                                                <input type="text" name="sekolah" value="<?php echo $data->sekolah; ?>" class="form-control form-control-sm fontInput" placeholder="Nama Lembaga" disabled>
                                                                                <input type="text" name="id" value="<?php echo $data->id; ?>" class="form-control form-control-sm fontInput" hidden>
                                                                            </div>
                                                                        </div>
                                                                        <div class="row">
                                                                            <label for="exampleEmail" class="col-lg-4 col-md-5 col-sm-12 col-form-label">Alamat </label>
                                                                            <div class="col-lg-8 col-md-7 col-sm-12">
                                                                                <input type="text" name="alamat" value="<?php echo $data->alamat; ?>" class="form-control form-control-sm fontInput" placeholder="Alamat">
                                                                            </div>
                                                                        </div>
                                                                        <div class="row">
                                                                            <label for="exampleEmail" class="col-sm-4 col-form-label">Kota </label>
                                                                            <div class="col-sm-8">
                                                                                <input type="text" name="kota" value="<?php echo $data->kota; ?>" class="form-control form-control-sm fontInput" placeholder="Kota">
                                                                            </div>
                                                                        </div>
                                                                        <div class="row">
                                                                            <label class="col-sm-4 col-form-label">Tahun Pelajaran Default</label>
                                                                            <div class="col-md-8">
                                                                                <select name="tp" class="form-control form-control-sm fontInput small" required>
                                                                                    <option><?php echo $data->tp; ?></option>
                                                                                    <?php
                                                                                    $opt = new form();
                                                                                    $opval = $opt->optSelect('tb_tp', 'order by tp asc');
                                                                                    while ($dataopt = $opval->fetch(PDO::FETCH_OBJ)) {
                                                                                        echo "<option>$dataopt->tp</option>";
                                                                                    };
                                                                                    ?>
                                                                                </select>
                                                                            </div>
                                                                        </div>

                                                                        <div class="row">
                                                                            <label for="nis" class="col-sm-4 col-form-label">Nama Pimpinan</label>
                                                                            <div class="col-sm-8">
                                                                                <input type="text" class="form-control form-control-sm fontInput" value="<?php echo $data->nama_pimpinan; ?>" placeholder="Nama Pimpinan" name="nama_pimpinan">

                                                                            </div>
                                                                        </div>
                                                                        <div class="row">
                                                                            <label for="nis" class="col-sm-4 col-form-label">Istilah Pimpinan</label>
                                                                            <div class="col-sm-8">
                                                                                <input type="text" class="form-control form-control-sm fontInput" value="<?php echo $data->pimpinan; ?>" placeholder="Istilah Pimpinan" name="pimpinan">

                                                                            </div>
                                                                        </div>
                                                                        <div class="row">
                                                                            <label class="col-sm-4 col-form-label">Nama pada Kuitansi</label>
                                                                            <div class="col-md-8">
                                                                                <select name="nama_kuitansi" class="form-control form-control-sm fontInput small" required>
                                                                                    <option><?php echo $data->nama_kuitansi; ?></option>
                                                                                    <option>Nama Siswa</option>
                                                                                    <option>Nama Orang Tua</option>
                                                                                </select>
                                                                            </div>
                                                                        </div>

                                                                        <div class="row">
                                                                            <label class="col-sm-4 col-form-label">Model Kuitansi</label>
                                                                            <div class="col-md-8">
                                                                                <select name="model_kw" class="form-control form-control-sm fontInput small" required>
                                                                                    <option value="<?php echo $data->model_kw; ?>">
                                                                                        <?php
                                                                                        $optVal = new Lembaga();
                                                                                        $val = $optVal->ValKuitansi($data->model_kw);
                                                                                        echo $val;
                                                                                        ?>
                                                                                    </option>
                                                                                    <option value="1">Model - 1</option>
                                                                                    <option value="2">Model - 2</option>
                                                                                    <option value="3">Model - 3</option>
                                                                                    <option value="4">Model - 4</option>
                                                                                    <option value="5">Model - 5 [Uk. 12 x 14 cm]</option>
                                                                                    <option value="6">Model - 6 [Uk. 10 x 16.5 cm]</option>

                                                                                </select>
                                                                                </select>
                                                                            </div>
                                                                        </div>
                                                                        <div class="row">
                                                                            <label class="col-sm-4 col-form-label">Kops Kuitansi</label>
                                                                            <div class="col-sm-8">
                                                                                <input type="text" class="form-control form-control-sm fontInput" value="<?php echo $data->sekolah; ?>" name="kops1" disabled>
                                                                            </div>

                                                                        </div>
                                                                        <div class="row">
                                                                            <label for="nis" class="col-sm-4 col-form-label"></label>
                                                                            <div class="col-sm-8">
                                                                                <input type="text" class="form-control form-control-sm fontInput" value="<?php echo $data->kops2; ?>" name="kops2">
                                                                            </div>
                                                                        </div>
                                                                        <div class="row mt-2">
                                                                            <label for="nis" class="col-sm-4 col-form-label">Seting Cetak Kuitansi</label>
                                                                            <div class="col-sm-8">
                                                                                <input name="info_kuitansi" type="checkbox" value="ya" <?php $cek = new Lembaga;
                                                                                                                                        echo  $cek->checkValue($data->info_kuitansi, 'ya')
                                                                                                                                        ?>><label class="control-label text-dark"> &nbsp; Tampilkan Informasi Tanggungan pada Kuitansi</label></br>
                                                                                <input name="info_tahap" type="checkbox" value="ya" <?php $cek = new Lembaga;
                                                                                                                                    echo  $cek->checkValue($data->info_tahap, 'ya')
                                                                                                                                    ?>><label class="control-label text-dark"> &nbsp; Tampilkan Informasi Tahap / Bulan</label></br>
                                                                                <input name="info_kettrans" type="checkbox" value="ya" <?php $cek = new Lembaga;
                                                                                                                                        echo  $cek->checkValue($data->info_kettrans, 'ya')
                                                                                                                                        ?>><label class="control-label text-dark"> &nbsp; Keterangan Tunai/Bank-ID Transaksi-Penerima</label>

                                                                                <label class="col-sm-12 col-form-label"><i class="text-secondary"><i class="bi bi-chat-text"></i> Teks "Terima Kasih" pada Kuitansi</i></label>
                                                                                <input type="text" class="form-control form-control-sm fontInput" value="<?php echo $data->tk; ?>" name="tk">

                                                                            </div>
                                                                        </div>
                                                                        <div class="row">
                                                                            <label class="col-sm-4 col-form-label">Catatan Kuitansi [Model-4]</label>
                                                                            <div class="col-sm-8">
                                                                                <label class="col-sm-12 col-form-label"><i class="text-secondary"><i class="bi bi-body-text"></i> Teks 1</i></label>
                                                                                <textarea name="notice" class="form-control fontInput col-xs-12" rows="4"><?php echo $data->notice; ?></textarea>
                                                                            </div>
                                                                        </div>
                                                                        <div class="row">
                                                                            <label class="col-sm-4 col-form-label"></label>
                                                                            <div class="col-sm-8">
                                                                                <label class="col-sm-12 col-form-label"><i class="text-secondary"><i class="bi bi-body-text"></i> Teks 2</i></label>
                                                                                <textarea name="notice2" class="form-control fontInput col-xs-12"><?php echo $data->notice2; ?></textarea>
                                                                            </div>
                                                                        </div>
                                                                        <div class="my-2 pl-3 py-2 mx-2">
                                                                            <div class="row">
                                                                                <div class="col-auto">
                                                                                    <a <?php echo $link->page('beranda'); ?> class="btn btn-primary btn-xs float-right mx-2"><i class="bi-arrow-left-circle"></i> Cancel</a>
                                                                                    <button type="submit" class="btn btn-primary btn-xs float-right" name="submit"><i class="bi-save"></i> Simpan</button>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                        </form>
                                                        <div class="row">
                                                            <label class="col-sm-4 col-form-label"></label>
                                                            <div class="col-sm-8">
                                                                <label class="col-sm-12 col-form-label"><i class="text-secondary"><i class="bi bi-body-text"></i> Logo Lembaga</i></label>
                                                                <div class="modal-body" align="left">
                                                                    <?php
                                                                    $view = new Lembaga;
                                                                    echo $view->viewImage('../../asset/dokumen/foto/', 'logo', 'img-thumbnail', '150', '150'); ?>
                                                                </div>
                                                                <form action="" method="post" enctype="multipart/form-data">
                                                                    <input type="file" name="fileLogo" class="pl-3" accept=".png,.jpg" required />
                                                                    <input type="submit" name="uploadlogo" value="Upload" />
                                                                </form>
                                                            </div>
                                                        </div>

                                                    </div>
                                                </div>
                                            </div>

                                        </div>

                                    </div>
                                </div>



                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</div>
</div>

<?php

$lembaga = new lembaga();
if (isset($_POST['submit'])) {
    $csrf = $csrf->cekToken();
    $lembaga->saveLembaga();
} elseif (isset($_POST['uploadback'])) {
    echo $lembaga->delImage('../../asset/dokumen/foto/', 'kops');
    echo $lembaga->UploadImage('../../asset/dokumen/foto/', 'kops', '50', 'fileBack', 'uploadback');
} elseif (isset($_POST['uploadlogo'])) {
    echo $lembaga->delImage('../../asset/dokumen/foto/', 'logo');
    echo $lembaga->UploadImage('../../asset/dokumen/foto/', 'logo', '50', 'fileLogo', 'uploadlogo');
} else {
    echo '';
}
