<?php

namespace PHPMaker2021\rdigital21;

// Table
$proyek = Container("proyek");
?>
<?php if ($proyek->Visible) { ?>
<div class="ew-master-div">
<table id="tbl_proyekmaster" class="table ew-view-table ew-master-table ew-vertical d-none">
    <tbody>
<?php if ($proyek->project_id->Visible) { // project_id ?>
        <tr id="r_project_id">
            <td class="<?= $proyek->TableLeftColumnClass ?>"><template id="tpc_proyek_project_id"><?= $proyek->project_id->caption() ?></template></td>
            <td <?= $proyek->project_id->cellAttributes() ?>>
<template id="tpx_proyek_project_id" class="proyekmaster">
<?php
$project_id=$proyek->project_id->getViewValue();
$tahun_pelajaran=$proyek->tahun_pelajaran->getViewValue();
$project=$proyek->project->getViewValue();
$kelas=$proyek->kelas->getViewValue();
$gdimensi=ExecuteScalar("SELECT dimensi FROM proyek where project_id='$project_id'"); 
$txt=$project_id."|".$tahun_pelajaran."|".$project."|".$gdimensi."|".$kelas;
$cek = ExecuteScalar("SELECT COUNT(*) FROM nilai_p5 WHERE project_id='$project_id'");
if ($cek==0) {
    echo '<a href="act.php?p5='.base64_encode($txt).'" class="btn btn-success btn-sm">Generate Nilai P5</a>';
} else { ?>
   <button class="btn btn-secondary btn-sm" onclick="alert('Data Nilai Sudah Ada')">Generate Berhasil</button>
<?php } ?>
</template>
<template id="tpx_proyek_project_id"><span id="el_proyek_project_id">
<span<?= $proyek->project_id->viewAttributes() ?>><slot name="tpx_proyek_project_id"></slot></span>
</span></template>
</td>
        </tr>
<?php } ?>
<?php if ($proyek->tahun_pelajaran->Visible) { // tahun_pelajaran ?>
        <tr id="r_tahun_pelajaran">
            <td class="<?= $proyek->TableLeftColumnClass ?>"><template id="tpc_proyek_tahun_pelajaran"><?= $proyek->tahun_pelajaran->caption() ?></template></td>
            <td <?= $proyek->tahun_pelajaran->cellAttributes() ?>>
<template id="tpx_proyek_tahun_pelajaran"><span id="el_proyek_tahun_pelajaran">
<span<?= $proyek->tahun_pelajaran->viewAttributes() ?>>
<?= $proyek->tahun_pelajaran->getViewValue() ?></span>
</span></template>
</td>
        </tr>
<?php } ?>
<?php if ($proyek->kelas->Visible) { // kelas ?>
        <tr id="r_kelas">
            <td class="<?= $proyek->TableLeftColumnClass ?>"><template id="tpc_proyek_kelas"><?= $proyek->kelas->caption() ?></template></td>
            <td <?= $proyek->kelas->cellAttributes() ?>>
<template id="tpx_proyek_kelas"><span id="el_proyek_kelas">
<span<?= $proyek->kelas->viewAttributes() ?>>
<?= $proyek->kelas->getViewValue() ?></span>
</span></template>
</td>
        </tr>
<?php } ?>
<?php if ($proyek->project->Visible) { // project ?>
        <tr id="r_project">
            <td class="<?= $proyek->TableLeftColumnClass ?>"><template id="tpc_proyek_project"><?= $proyek->project->caption() ?></template></td>
            <td <?= $proyek->project->cellAttributes() ?>>
<template id="tpx_proyek_project"><span id="el_proyek_project">
<span<?= $proyek->project->viewAttributes() ?>>
<?= $proyek->project->getViewValue() ?></span>
</span></template>
</td>
        </tr>
<?php } ?>
<?php if ($proyek->nama_proyek->Visible) { // nama_proyek ?>
        <tr id="r_nama_proyek">
            <td class="<?= $proyek->TableLeftColumnClass ?>"><template id="tpc_proyek_nama_proyek"><?= $proyek->nama_proyek->caption() ?></template></td>
            <td <?= $proyek->nama_proyek->cellAttributes() ?>>
<template id="tpx_proyek_nama_proyek"><span id="el_proyek_nama_proyek">
<span<?= $proyek->nama_proyek->viewAttributes() ?>>
<?= $proyek->nama_proyek->getViewValue() ?></span>
</span></template>
</td>
        </tr>
<?php } ?>
<?php if ($proyek->tema->Visible) { // tema ?>
        <tr id="r_tema">
            <td class="<?= $proyek->TableLeftColumnClass ?>"><template id="tpc_proyek_tema"><?= $proyek->tema->caption() ?></template></td>
            <td <?= $proyek->tema->cellAttributes() ?>>
<template id="tpx_proyek_tema"><span id="el_proyek_tema">
<span<?= $proyek->tema->viewAttributes() ?>>
<?= $proyek->tema->getViewValue() ?></span>
</span></template>
</td>
        </tr>
<?php } ?>
<?php if ($proyek->dimensi->Visible) { // dimensi ?>
        <tr id="r_dimensi">
            <td class="<?= $proyek->TableLeftColumnClass ?>"><template id="tpc_proyek_dimensi"><?= $proyek->dimensi->caption() ?></template></td>
            <td <?= $proyek->dimensi->cellAttributes() ?>>
<template id="tpx_proyek_dimensi" class="proyekmaster">
<?php
 $project_id=$proyek->project_id->getViewValue();
 $gdimensi=ExecuteScalar("SELECT dimensi FROM proyek where project_id='$project_id'");
 echo count($dimensi=explode(",",$gdimensi))." Dimensi"; 
?>
</template>
<template id="tpx_proyek_dimensi"><span id="el_proyek_dimensi">
<span<?= $proyek->dimensi->viewAttributes() ?>><slot name="tpx_proyek_dimensi"></slot></span>
</span></template>
</td>
        </tr>
<?php } ?>
    </tbody>
</table>
</div>
<div id="tpd_proyekmaster" class="ew-custom-template"></div>
<template id="tpm_proyekmaster">
<div id="ct_ProyekMaster"><div class="card card-primary card-outline card-body">
	<table class="table table-striped table-sm ew-view-table"> 
    <tr id="r_tahun_pelajaran">
        <td class="w-col-2"><?= $proyek->tahun_pelajaran->caption() ?></td>
        <td><slot class="ew-slot" name="tpx_proyek_tahun_pelajaran"></slot></td>
    </tr>
    <tr id="r_kelas">
        <td class="w-col-2"><?= $proyek->kelas->caption() ?></td>
        <td><slot class="ew-slot" name="tpx_proyek_kelas"></slot></td>
    </tr>
    <tr id="r_project">
        <td class="w-col-2"><?= $proyek->project->caption() ?></td>
        <td><slot class="ew-slot" name="tpx_proyek_project"></slot></td>
    </tr>
    <tr id="r_nama_proyek">
        <td class="w-col-2"><?= $proyek->nama_proyek->caption() ?></td>
        <td><slot class="ew-slot" name="tpx_proyek_nama_proyek"></slot></td>
    </tr>
    <tr id="r_tema">
        <td class="w-col-2"><?= $proyek->tema->caption() ?></td>
        <td><slot class="ew-slot" name="tpx_proyek_tema"></slot></td>
    </tr>
    <tr id="r_dimensi">
        <td class="w-col-2"><?= $proyek->dimensi->caption() ?></td>
        <td><slot class="ew-slot" name="tpx_proyek_dimensi"></slot></td>
    </tr> 
</table>
</div>
</div>
</template>
<script class="ew-apply-template">
loadjs.ready(["jsrender", "makerjs"], function() {
    ew.templateData = { rows: <?= JsonEncode($proyek->Rows) ?> };
    ew.applyTemplate("tpd_proyekmaster", "tpm_proyekmaster", "proyekmaster", "<?= $proyek->CustomExport ?>", ew.templateData.rows[0]);
    loadjs.done("customtemplate");
});
</script>
<?php } ?>
