<?php 
//check if current user role is allowed access to the pages
$can_add = ACL::is_allowed("sppg/add");
$can_edit = ACL::is_allowed("sppg/edit");
$can_view = ACL::is_allowed("sppg/view");
$can_delete = ACL::is_allowed("sppg/delete");
?>
<?php
$comp_model = new SharedController;
$page_element_id = "view-page-" . random_str();
$current_page = $this->set_current_page_link();
$csrf_token = Csrf::$token;
//Page Data Information from Controller
$data = $this->view_data;
//$rec_id = $data['__tableprimarykey'];
$page_id = $this->route->page_id; //Page id from url
$view_title = $this->view_title;
$show_header = $this->show_header;
$show_edit_btn = $this->show_edit_btn;
$show_delete_btn = $this->show_delete_btn;
$show_export_btn = $this->show_export_btn;
?>
<section class="page" id="<?php echo $page_element_id; ?>" data-page-type="view"  data-display-type="table" data-page-url="<?php print_link($current_page); ?>">
    <?php
    if( $show_header == true ){
    ?>
    <div  class="bg-light p-3 mb-3">
        <div class="container">
            <div class="row ">
                <div class="col ">
                    <h4 class="record-title">View  Sppg</h4>
                </div>
            </div>
        </div>
    </div>
    <?php
    }
    ?>
    <div  class="">
        <div class="container">
            <div class="row ">
                <div class="col-md-12 comp-grid">
                    <?php $this :: display_page_errors(); ?>
                    <div  class="card animated fadeIn page-content">
                        <?php
                        $counter = 0;
                        if(!empty($data)){
                        $rec_id = (!empty($data['id_sppg']) ? urlencode($data['id_sppg']) : null);
                        $counter++;
                        ?>
                        <div id="page-report-body" class="">
                            <table class="table table-hover table-borderless table-striped">
                                <!-- Table Body Start -->
                                <tbody class="page-data" id="page-data-<?php echo $page_element_id; ?>">
                                    <tr  class="td-nama_sppg">
                                        <th class="title"> Nama Sppg: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['nama_sppg']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="nama_sppg" 
                                                data-title="Enter Nama Sppg" 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['nama_sppg']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-identitas_sppg">
                                        <th class="title"> ID SPPG: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['identitas_sppg']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="identitas_sppg" 
                                                data-title="Enter ID SPPG" 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['identitas_sppg']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-yayasan">
                                        <th class="title"> Yayasan: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['yayasan']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="yayasan" 
                                                data-title="Enter Nama Yayasan" 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['yayasan']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-asal_kabupaten">
                                        <th class="title"> Asal Kabupaten: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['asal_kabupaten']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="asal_kabupaten" 
                                                data-title="Enter Asal Kabupaten" 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['asal_kabupaten']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-tanggal_ops">
                                        <th class="title"> Tanggal Ops: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-flatpickr="{altFormat: 'd-m-Y', enableTime: false, minDate: '', maxDate: ''}" 
                                                data-value="<?php echo $data['tanggal_ops']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="tanggal_ops" 
                                                data-title="Enter Tanggal Operasional" 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="flatdatetimepicker" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['tanggal_ops']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-sertifikat_slhs">
                                        <th class="title"> Sertifikat SLHS: </th>
                                        <td class="value"><?php echo $data['sertifikat_slhs']; ?></td>
                                    </tr>
                                    <tr  class="td-sertifikat_halal">
                                        <th class="title"> Sertifikat Halal: </th>
                                        <td class="value"><?php echo $data['sertifikat_halal']; ?></td>
                                    </tr>
                                    <tr  class="td-sertifikat_kelayakan_air">
                                        <th class="title"> Sertifikat Kelayakan Air: </th>
                                        <td class="value"><?php echo $data['sertifikat_kelayakan_air']; ?></td>
                                    </tr>
                                    <tr  class="td-sertifikat_chef">
                                        <th class="title"> Sertifikat Chef: </th>
                                        <td class="value"><?php echo $data['sertifikat_chef']; ?></td>
                                    </tr>
                                    <tr  class="td-ipal">
                                        <th class="title"> Ipal: </th>
                                        <td class="value"><?php echo $data['ipal']; ?></td>
                                    </tr>
                                    <tr  class="td-pm_bumil">
                                        <th class="title"> Pm Bumil: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['pm_bumil']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="pm_bumil" 
                                                data-title="Enter PM Bumil" 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['pm_bumil']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-pm_busui">
                                        <th class="title"> Pm Busui: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['pm_busui']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="pm_busui" 
                                                data-title="Enter PM Busui" 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['pm_busui']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-pm_balita">
                                        <th class="title"> Pm Balita: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['pm_balita']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="pm_balita" 
                                                data-title="Enter PM Balita" 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['pm_balita']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-pm_sekolah">
                                        <th class="title"> Pm Sekolah: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['pm_sekolah']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="pm_sekolah" 
                                                data-title="Enter PM Sekolah" 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['pm_sekolah']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-Total_PM">
                                        <th class="title"> Total PM: </th>
                                        <td class="value"> <?php echo $data['Total_PM']; ?></td>
                                    </tr>
                                    <tr  class="td-jumlah_relawan">
                                        <th class="title"> Jumlah Relawan: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['jumlah_relawan']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="jumlah_relawan" 
                                                data-title="Enter Jumlah Relawan" 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['jumlah_relawan']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-link_gmaps">
                                        <th class="title"> Link Gmaps: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['link_gmaps']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="link_gmaps" 
                                                data-title="format : https://....." 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['link_gmaps']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-link_slhs">
                                        <th class="title"> Link Sertifikat SLHS: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['link_slhs']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="link_slhs" 
                                                data-title="format : https://....." 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['link_slhs']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-link_halal">
                                        <th class="title"> Link Sertifikat Halal: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['link_halal']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="link_halal" 
                                                data-title="format : https://....." 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['link_halal']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                    <tr  class="td-link_air">
                                        <th class="title"> Link Sertifikat Kelayakan Air: </th>
                                        <td class="value">
                                            <span <?php if($can_edit){ ?> data-value="<?php echo $data['link_air']; ?>" 
                                                data-pk="<?php echo $data['id_sppg'] ?>" 
                                                data-url="<?php print_link("sppg/editfield/" . urlencode($data['id_sppg'])); ?>" 
                                                data-name="link_air" 
                                                data-title="format : https://....." 
                                                data-placement="left" 
                                                data-toggle="click" 
                                                data-type="text" 
                                                data-mode="popover" 
                                                data-showbuttons="left" 
                                                class="is-editable" <?php } ?>>
                                                <?php echo $data['link_air']; ?> 
                                            </span>
                                        </td>
                                    </tr>
                                </tbody>
                                <!-- Table Body End -->
                            </table>
                        </div>
                        <div class="p-3 d-flex">
                            <div class="dropup export-btn-holder mx-1">
                                <button class="btn btn-sm btn-primary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                    <i class="fa fa-save"></i> Export
                                </button>
                                <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                                    <?php $export_print_link = $this->set_current_page_link(array('format' => 'print')); ?>
                                    <a class="dropdown-item export-link-btn" data-format="print" href="<?php print_link($export_print_link); ?>" target="_blank">
                                        <img src="<?php print_link('assets/images/print.png') ?>" class="mr-2" /> PRINT
                                        </a>
                                        <?php $export_pdf_link = $this->set_current_page_link(array('format' => 'pdf')); ?>
                                        <a class="dropdown-item export-link-btn" data-format="pdf" href="<?php print_link($export_pdf_link); ?>" target="_blank">
                                            <img src="<?php print_link('assets/images/pdf.png') ?>" class="mr-2" /> PDF
                                            </a>
                                            <?php $export_word_link = $this->set_current_page_link(array('format' => 'word')); ?>
                                            <a class="dropdown-item export-link-btn" data-format="word" href="<?php print_link($export_word_link); ?>" target="_blank">
                                                <img src="<?php print_link('assets/images/doc.png') ?>" class="mr-2" /> WORD
                                                </a>
                                                <?php $export_csv_link = $this->set_current_page_link(array('format' => 'csv')); ?>
                                                <a class="dropdown-item export-link-btn" data-format="csv" href="<?php print_link($export_csv_link); ?>" target="_blank">
                                                    <img src="<?php print_link('assets/images/csv.png') ?>" class="mr-2" /> CSV
                                                    </a>
                                                    <?php $export_excel_link = $this->set_current_page_link(array('format' => 'excel')); ?>
                                                    <a class="dropdown-item export-link-btn" data-format="excel" href="<?php print_link($export_excel_link); ?>" target="_blank">
                                                        <img src="<?php print_link('assets/images/xsl.png') ?>" class="mr-2" /> EXCEL
                                                        </a>
                                                    </div>
                                                </div>
                                            </div>
                                            <?php
                                            }
                                            else{
                                            ?>
                                            <!-- Empty Record Message -->
                                            <div class="text-muted p-3">
                                                <i class="fa fa-ban"></i> No Record Found
                                            </div>
                                            <?php
                                            }
                                            ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </section>
