<?php

namespace PHPMaker2021\rdigital21;

use Doctrine\DBAL\ParameterType;

/**
 * Table class for peserta_didik
 */
class PesertaDidik extends DbTable
{
    protected $SqlFrom = "";
    protected $SqlSelect = null;
    protected $SqlSelectList = null;
    protected $SqlWhere = "";
    protected $SqlGroupBy = "";
    protected $SqlHaving = "";
    protected $SqlOrderBy = "";
    public $UseSessionForListSql = true;

    // Column CSS classes
    public $LeftColumnClass = "col-sm-2 col-form-label ew-label";
    public $RightColumnClass = "col-sm-10";
    public $OffsetColumnClass = "col-sm-10 offset-sm-2";
    public $TableLeftColumnClass = "w-col-2";

    // Export
    public $ExportDoc;

    // Fields
    public $pd_id;
    public $kode_tapel;
    public $kelas;
    public $nisn;
    public $nis;
    public $nama;
    public $jk;
    public $tmp_lahir;
    public $tgl_lahir;
    public $agama;
    public $status;
    public $anak_ke;
    public $alamat_siswa;
    public $no_hp;
    public $sekolah_asal;
    public $diterima_di_kls;
    public $tanggal;
    public $nama_ayah;
    public $nama_ibu;
    public $alamat;
    public $telepon;
    public $kerja_ayah;
    public $kerja_ibu;
    public $nama_wali;
    public $no_telepon;
    public $alamat_wali;
    public $kerja_wali;

    // Page ID
    public $PageID = ""; // To be overridden by subclass

    // Constructor
    public function __construct()
    {
        global $Language, $CurrentLanguage;
        parent::__construct();

        // Language object
        $Language = Container("language");
        $this->TableVar = 'peserta_didik';
        $this->TableName = 'peserta_didik';
        $this->TableType = 'TABLE';

        // Update Table
        $this->UpdateTable = "\"peserta_didik\"";
        $this->Dbid = 'DB';
        $this->ExportAll = true;
        $this->ExportPageBreakCount = 0; // Page break per every n record (PDF only)
        $this->ExportPageOrientation = "portrait"; // Page orientation (PDF only)
        $this->ExportPageSize = "a4"; // Page size (PDF only)
        $this->ExportExcelPageOrientation = ""; // Page orientation (PhpSpreadsheet only)
        $this->ExportExcelPageSize = ""; // Page size (PhpSpreadsheet only)
        $this->ExportWordPageOrientation = "portrait"; // Page orientation (PHPWord only)
        $this->ExportWordColumnWidth = null; // Cell width (PHPWord only)
        $this->DetailAdd = false; // Allow detail add
        $this->DetailEdit = false; // Allow detail edit
        $this->DetailView = false; // Allow detail view
        $this->ShowMultipleDetails = false; // Show multiple details
        $this->GridAddRowCount = 5;
        $this->AllowAddDeleteRow = true; // Allow add/delete row
        $this->BasicSearch = new BasicSearch($this->TableVar);

        // pd_id
        $this->pd_id = new DbField('peserta_didik', 'peserta_didik', 'x_pd_id', 'pd_id', '"pd_id"', '"pd_id"', 3, 0, -1, false, '"pd_id"', false, false, false, 'FORMATTED TEXT', 'NO');
        $this->pd_id->IsAutoIncrement = true; // Autoincrement field
        $this->pd_id->IsPrimaryKey = true; // Primary key field
        $this->pd_id->Nullable = false; // NOT NULL field
        $this->pd_id->Sortable = true; // Allow sort
        $this->pd_id->DefaultErrorMessage = $Language->phrase("IncorrectInteger");
        $this->pd_id->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->pd_id->Param, "CustomMsg");
        $this->Fields['pd_id'] = &$this->pd_id;

        // kode_tapel
        $this->kode_tapel = new DbField('peserta_didik', 'peserta_didik', 'x_kode_tapel', 'kode_tapel', '"kode_tapel"', '"kode_tapel"', 203, 255, -1, false, '"kode_tapel"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->kode_tapel->Nullable = false; // NOT NULL field
        $this->kode_tapel->Sortable = true; // Allow sort
        $this->kode_tapel->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->kode_tapel->Param, "CustomMsg");
        $this->Fields['kode_tapel'] = &$this->kode_tapel;

        // kelas
        $this->kelas = new DbField('peserta_didik', 'peserta_didik', 'x_kelas', 'kelas', '"kelas"', '"kelas"', 203, 255, -1, false, '"kelas"', false, false, false, 'FORMATTED TEXT', 'SELECT');
        $this->kelas->Sortable = true; // Allow sort
        $this->kelas->UsePleaseSelect = true; // Use PleaseSelect by default
        $this->kelas->PleaseSelectText = $Language->phrase("PleaseSelect"); // "PleaseSelect" text
        $this->kelas->Lookup = new Lookup('kelas', 'peserta_didik', true, 'kelas', ["kelas","","",""], [], [], [], [], [], [], '"kelas" ASC', '');
        $this->kelas->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->kelas->Param, "CustomMsg");
        $this->Fields['kelas'] = &$this->kelas;

        // nisn
        $this->nisn = new DbField('peserta_didik', 'peserta_didik', 'x_nisn', 'nisn', '"nisn"', '"nisn"', 203, 255, -1, false, '"nisn"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->nisn->Sortable = true; // Allow sort
        $this->nisn->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->nisn->Param, "CustomMsg");
        $this->Fields['nisn'] = &$this->nisn;

        // nis
        $this->nis = new DbField('peserta_didik', 'peserta_didik', 'x_nis', 'nis', '"nis"', '"nis"', 203, 255, -1, false, '"nis"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->nis->Sortable = true; // Allow sort
        $this->nis->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->nis->Param, "CustomMsg");
        $this->Fields['nis'] = &$this->nis;

        // nama
        $this->nama = new DbField('peserta_didik', 'peserta_didik', 'x_nama', 'nama', '"nama"', '"nama"', 203, 255, -1, false, '"nama"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->nama->Sortable = true; // Allow sort
        $this->nama->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->nama->Param, "CustomMsg");
        $this->Fields['nama'] = &$this->nama;

        // jk
        $this->jk = new DbField('peserta_didik', 'peserta_didik', 'x_jk', 'jk', '"jk"', '"jk"', 203, 255, -1, false, '"jk"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->jk->Sortable = true; // Allow sort
        $this->jk->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->jk->Param, "CustomMsg");
        $this->Fields['jk'] = &$this->jk;

        // tmp_lahir
        $this->tmp_lahir = new DbField('peserta_didik', 'peserta_didik', 'x_tmp_lahir', 'tmp_lahir', '"tmp_lahir"', '"tmp_lahir"', 203, 255, -1, false, '"tmp_lahir"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->tmp_lahir->Sortable = true; // Allow sort
        $this->tmp_lahir->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->tmp_lahir->Param, "CustomMsg");
        $this->Fields['tmp_lahir'] = &$this->tmp_lahir;

        // tgl_lahir
        $this->tgl_lahir = new DbField('peserta_didik', 'peserta_didik', 'x_tgl_lahir', 'tgl_lahir', '"tgl_lahir"', '"tgl_lahir"', 203, 255, -1, false, '"tgl_lahir"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->tgl_lahir->Sortable = true; // Allow sort
        $this->tgl_lahir->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->tgl_lahir->Param, "CustomMsg");
        $this->Fields['tgl_lahir'] = &$this->tgl_lahir;

        // agama
        $this->agama = new DbField('peserta_didik', 'peserta_didik', 'x_agama', 'agama', '"agama"', '"agama"', 203, 255, -1, false, '"agama"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->agama->Sortable = true; // Allow sort
        $this->agama->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->agama->Param, "CustomMsg");
        $this->Fields['agama'] = &$this->agama;

        // status
        $this->status = new DbField('peserta_didik', 'peserta_didik', 'x_status', 'status', '"status"', '"status"', 203, 255, -1, false, '"status"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->status->Sortable = true; // Allow sort
        $this->status->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->status->Param, "CustomMsg");
        $this->Fields['status'] = &$this->status;

        // anak_ke
        $this->anak_ke = new DbField('peserta_didik', 'peserta_didik', 'x_anak_ke', 'anak_ke', '"anak_ke"', '"anak_ke"', 203, 255, -1, false, '"anak_ke"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->anak_ke->Sortable = true; // Allow sort
        $this->anak_ke->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->anak_ke->Param, "CustomMsg");
        $this->Fields['anak_ke'] = &$this->anak_ke;

        // alamat_siswa
        $this->alamat_siswa = new DbField('peserta_didik', 'peserta_didik', 'x_alamat_siswa', 'alamat_siswa', '"alamat_siswa"', '"alamat_siswa"', 203, 255, -1, false, '"alamat_siswa"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->alamat_siswa->Sortable = true; // Allow sort
        $this->alamat_siswa->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->alamat_siswa->Param, "CustomMsg");
        $this->Fields['alamat_siswa'] = &$this->alamat_siswa;

        // no_hp
        $this->no_hp = new DbField('peserta_didik', 'peserta_didik', 'x_no_hp', 'no_hp', '"no_hp"', '"no_hp"', 203, 255, -1, false, '"no_hp"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->no_hp->Sortable = true; // Allow sort
        $this->no_hp->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->no_hp->Param, "CustomMsg");
        $this->Fields['no_hp'] = &$this->no_hp;

        // sekolah_asal
        $this->sekolah_asal = new DbField('peserta_didik', 'peserta_didik', 'x_sekolah_asal', 'sekolah_asal', '"sekolah_asal"', '"sekolah_asal"', 203, 255, -1, false, '"sekolah_asal"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->sekolah_asal->Sortable = true; // Allow sort
        $this->sekolah_asal->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->sekolah_asal->Param, "CustomMsg");
        $this->Fields['sekolah_asal'] = &$this->sekolah_asal;

        // diterima_di_kls
        $this->diterima_di_kls = new DbField('peserta_didik', 'peserta_didik', 'x_diterima_di_kls', 'diterima_di_kls', '"diterima_di_kls"', '"diterima_di_kls"', 203, 255, -1, false, '"diterima_di_kls"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->diterima_di_kls->Sortable = true; // Allow sort
        $this->diterima_di_kls->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->diterima_di_kls->Param, "CustomMsg");
        $this->Fields['diterima_di_kls'] = &$this->diterima_di_kls;

        // tanggal
        $this->tanggal = new DbField('peserta_didik', 'peserta_didik', 'x_tanggal', 'tanggal', '"tanggal"', '"tanggal"', 203, 255, -1, false, '"tanggal"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->tanggal->Sortable = true; // Allow sort
        $this->tanggal->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->tanggal->Param, "CustomMsg");
        $this->Fields['tanggal'] = &$this->tanggal;

        // nama_ayah
        $this->nama_ayah = new DbField('peserta_didik', 'peserta_didik', 'x_nama_ayah', 'nama_ayah', '"nama_ayah"', '"nama_ayah"', 203, 255, -1, false, '"nama_ayah"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->nama_ayah->Sortable = true; // Allow sort
        $this->nama_ayah->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->nama_ayah->Param, "CustomMsg");
        $this->Fields['nama_ayah'] = &$this->nama_ayah;

        // nama_ibu
        $this->nama_ibu = new DbField('peserta_didik', 'peserta_didik', 'x_nama_ibu', 'nama_ibu', '"nama_ibu"', '"nama_ibu"', 203, 255, -1, false, '"nama_ibu"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->nama_ibu->Sortable = true; // Allow sort
        $this->nama_ibu->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->nama_ibu->Param, "CustomMsg");
        $this->Fields['nama_ibu'] = &$this->nama_ibu;

        // alamat
        $this->alamat = new DbField('peserta_didik', 'peserta_didik', 'x_alamat', 'alamat', '"alamat"', '"alamat"', 203, 255, -1, false, '"alamat"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->alamat->Sortable = true; // Allow sort
        $this->alamat->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->alamat->Param, "CustomMsg");
        $this->Fields['alamat'] = &$this->alamat;

        // telepon
        $this->telepon = new DbField('peserta_didik', 'peserta_didik', 'x_telepon', 'telepon', '"telepon"', '"telepon"', 203, 255, -1, false, '"telepon"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->telepon->Sortable = true; // Allow sort
        $this->telepon->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->telepon->Param, "CustomMsg");
        $this->Fields['telepon'] = &$this->telepon;

        // kerja_ayah
        $this->kerja_ayah = new DbField('peserta_didik', 'peserta_didik', 'x_kerja_ayah', 'kerja_ayah', '"kerja_ayah"', '"kerja_ayah"', 203, 255, -1, false, '"kerja_ayah"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->kerja_ayah->Sortable = true; // Allow sort
        $this->kerja_ayah->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->kerja_ayah->Param, "CustomMsg");
        $this->Fields['kerja_ayah'] = &$this->kerja_ayah;

        // kerja_ibu
        $this->kerja_ibu = new DbField('peserta_didik', 'peserta_didik', 'x_kerja_ibu', 'kerja_ibu', '"kerja_ibu"', '"kerja_ibu"', 203, 255, -1, false, '"kerja_ibu"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->kerja_ibu->Sortable = true; // Allow sort
        $this->kerja_ibu->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->kerja_ibu->Param, "CustomMsg");
        $this->Fields['kerja_ibu'] = &$this->kerja_ibu;

        // nama_wali
        $this->nama_wali = new DbField('peserta_didik', 'peserta_didik', 'x_nama_wali', 'nama_wali', '"nama_wali"', '"nama_wali"', 203, 255, -1, false, '"nama_wali"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->nama_wali->Sortable = true; // Allow sort
        $this->nama_wali->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->nama_wali->Param, "CustomMsg");
        $this->Fields['nama_wali'] = &$this->nama_wali;

        // no_telepon
        $this->no_telepon = new DbField('peserta_didik', 'peserta_didik', 'x_no_telepon', 'no_telepon', '"no_telepon"', '"no_telepon"', 203, 255, -1, false, '"no_telepon"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->no_telepon->Sortable = true; // Allow sort
        $this->no_telepon->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->no_telepon->Param, "CustomMsg");
        $this->Fields['no_telepon'] = &$this->no_telepon;

        // alamat_wali
        $this->alamat_wali = new DbField('peserta_didik', 'peserta_didik', 'x_alamat_wali', 'alamat_wali', '"alamat_wali"', '"alamat_wali"', 203, 255, -1, false, '"alamat_wali"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->alamat_wali->Sortable = true; // Allow sort
        $this->alamat_wali->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->alamat_wali->Param, "CustomMsg");
        $this->Fields['alamat_wali'] = &$this->alamat_wali;

        // kerja_wali
        $this->kerja_wali = new DbField('peserta_didik', 'peserta_didik', 'x_kerja_wali', 'kerja_wali', '"kerja_wali"', '"kerja_wali"', 203, 255, -1, false, '"kerja_wali"', false, false, false, 'FORMATTED TEXT', 'TEXT');
        $this->kerja_wali->Sortable = true; // Allow sort
        $this->kerja_wali->CustomMsg = $Language->FieldPhrase($this->TableVar, $this->kerja_wali->Param, "CustomMsg");
        $this->Fields['kerja_wali'] = &$this->kerja_wali;
    }

    // Field Visibility
    public function getFieldVisibility($fldParm)
    {
        global $Security;
        return $this->$fldParm->Visible; // Returns original value
    }

    // Set left column class (must be predefined col-*-* classes of Bootstrap grid system)
    public function setLeftColumnClass($class)
    {
        if (preg_match('/^col\-(\w+)\-(\d+)$/', $class, $match)) {
            $this->LeftColumnClass = $class . " col-form-label ew-label";
            $this->RightColumnClass = "col-" . $match[1] . "-" . strval(12 - (int)$match[2]);
            $this->OffsetColumnClass = $this->RightColumnClass . " " . str_replace("col-", "offset-", $class);
            $this->TableLeftColumnClass = preg_replace('/^col-\w+-(\d+)$/', "w-col-$1", $class); // Change to w-col-*
        }
    }

    // Single column sort
    public function updateSort(&$fld)
    {
        if ($this->CurrentOrder == $fld->Name) {
            $sortField = $fld->Expression;
            $lastSort = $fld->getSort();
            if (in_array($this->CurrentOrderType, ["ASC", "DESC", "NO"])) {
                $curSort = $this->CurrentOrderType;
            } else {
                $curSort = $lastSort;
            }
            $fld->setSort($curSort);
            $orderBy = in_array($curSort, ["ASC", "DESC"]) ? $sortField . " " . $curSort : "";
            $this->setSessionOrderBy($orderBy); // Save to Session
        } else {
            $fld->setSort("");
        }
    }

    // Table level SQL
    public function getSqlFrom() // From
    {
        return ($this->SqlFrom != "") ? $this->SqlFrom : "\"peserta_didik\"";
    }

    public function sqlFrom() // For backward compatibility
    {
        return $this->getSqlFrom();
    }

    public function setSqlFrom($v)
    {
        $this->SqlFrom = $v;
    }

    public function getSqlSelect() // Select
    {
        return $this->SqlSelect ?? $this->getQueryBuilder()->select("*");
    }

    public function sqlSelect() // For backward compatibility
    {
        return $this->getSqlSelect();
    }

    public function setSqlSelect($v)
    {
        $this->SqlSelect = $v;
    }

    public function getSqlWhere() // Where
    {
        $where = ($this->SqlWhere != "") ? $this->SqlWhere : "";
        $this->DefaultFilter = "`kode_tapel`='".kode_tapel()."'";
        AddFilter($where, $this->DefaultFilter);
        return $where;
    }

    public function sqlWhere() // For backward compatibility
    {
        return $this->getSqlWhere();
    }

    public function setSqlWhere($v)
    {
        $this->SqlWhere = $v;
    }

    public function getSqlGroupBy() // Group By
    {
        return ($this->SqlGroupBy != "") ? $this->SqlGroupBy : "";
    }

    public function sqlGroupBy() // For backward compatibility
    {
        return $this->getSqlGroupBy();
    }

    public function setSqlGroupBy($v)
    {
        $this->SqlGroupBy = $v;
    }

    public function getSqlHaving() // Having
    {
        return ($this->SqlHaving != "") ? $this->SqlHaving : "";
    }

    public function sqlHaving() // For backward compatibility
    {
        return $this->getSqlHaving();
    }

    public function setSqlHaving($v)
    {
        $this->SqlHaving = $v;
    }

    public function getSqlOrderBy() // Order By
    {
        return ($this->SqlOrderBy != "") ? $this->SqlOrderBy : $this->DefaultSort;
    }

    public function sqlOrderBy() // For backward compatibility
    {
        return $this->getSqlOrderBy();
    }

    public function setSqlOrderBy($v)
    {
        $this->SqlOrderBy = $v;
    }

    // Apply User ID filters
    public function applyUserIDFilters($filter)
    {
        global $Security;
        // Add User ID filter
        if ($Security->currentUserID() != "" && !$Security->isAdmin()) { // Non system admin
            $filter = $this->addUserIDFilter($filter);
        }
        return $filter;
    }

    // Check if User ID security allows view all
    public function userIDAllow($id = "")
    {
        $allow = $this->UserIDAllowSecurity;
        switch ($id) {
            case "add":
            case "copy":
            case "gridadd":
            case "register":
            case "addopt":
                return (($allow & 1) == 1);
            case "edit":
            case "gridedit":
            case "update":
            case "changepassword":
            case "resetpassword":
                return (($allow & 4) == 4);
            case "delete":
                return (($allow & 2) == 2);
            case "view":
                return (($allow & 32) == 32);
            case "search":
                return (($allow & 64) == 64);
            default:
                return (($allow & 8) == 8);
        }
    }

    /**
     * Get record count
     *
     * @param string|QueryBuilder $sql SQL or QueryBuilder
     * @param mixed $c Connection
     * @return int
     */
    public function getRecordCount($sql, $c = null)
    {
        $cnt = -1;
        $rs = null;
        if ($sql instanceof \Doctrine\DBAL\Query\QueryBuilder) { // Query builder
            $sqlwrk = clone $sql;
            $sqlwrk = $sqlwrk->resetQueryPart("orderBy")->getSQL();
        } else {
            $sqlwrk = $sql;
        }
        $pattern = '/^SELECT\s([\s\S]+)\sFROM\s/i';
        // Skip Custom View / SubQuery / SELECT DISTINCT / ORDER BY
        if (
            ($this->TableType == 'TABLE' || $this->TableType == 'VIEW' || $this->TableType == 'LINKTABLE') &&
            preg_match($pattern, $sqlwrk) && !preg_match('/\(\s*(SELECT[^)]+)\)/i', $sqlwrk) &&
            !preg_match('/^\s*select\s+distinct\s+/i', $sqlwrk) && !preg_match('/\s+order\s+by\s+/i', $sqlwrk)
        ) {
            $sqlwrk = "SELECT COUNT(*) FROM " . preg_replace($pattern, "", $sqlwrk);
        } else {
            $sqlwrk = "SELECT COUNT(*) FROM (" . $sqlwrk . ") COUNT_TABLE";
        }
        $conn = $c ?? $this->getConnection();
        $rs = $conn->executeQuery($sqlwrk);
        $cnt = $rs->fetchColumn();
        if ($cnt !== false) {
            return (int)$cnt;
        }

        // Unable to get count by SELECT COUNT(*), execute the SQL to get record count directly
        return ExecuteRecordCount($sql, $conn);
    }

    // Get SQL
    public function getSql($where, $orderBy = "")
    {
        return $this->buildSelectSql(
            $this->getSqlSelect(),
            $this->getSqlFrom(),
            $this->getSqlWhere(),
            $this->getSqlGroupBy(),
            $this->getSqlHaving(),
            $this->getSqlOrderBy(),
            $where,
            $orderBy
        )->getSQL();
    }

    // Table SQL
    public function getCurrentSql()
    {
        $filter = $this->CurrentFilter;
        $filter = $this->applyUserIDFilters($filter);
        $sort = $this->getSessionOrderBy();
        return $this->getSql($filter, $sort);
    }

    /**
     * Table SQL with List page filter
     *
     * @return QueryBuilder
     */
    public function getListSql()
    {
        $filter = $this->UseSessionForListSql ? $this->getSessionWhere() : "";
        AddFilter($filter, $this->CurrentFilter);
        $filter = $this->applyUserIDFilters($filter);
        $this->recordsetSelecting($filter);
        $select = $this->getSqlSelect();
        $from = $this->getSqlFrom();
        $sort = $this->UseSessionForListSql ? $this->getSessionOrderBy() : "";
        $this->Sort = $sort;
        return $this->buildSelectSql(
            $select,
            $from,
            $this->getSqlWhere(),
            $this->getSqlGroupBy(),
            $this->getSqlHaving(),
            $this->getSqlOrderBy(),
            $filter,
            $sort
        );
    }

    // Get ORDER BY clause
    public function getOrderBy()
    {
        $orderBy = $this->getSqlOrderBy();
        $sort = $this->getSessionOrderBy();
        if ($orderBy != "" && $sort != "") {
            $orderBy .= ", " . $sort;
        } elseif ($sort != "") {
            $orderBy = $sort;
        }
        return $orderBy;
    }

    // Get record count based on filter (for detail record count in master table pages)
    public function loadRecordCount($filter)
    {
        $origFilter = $this->CurrentFilter;
        $this->CurrentFilter = $filter;
        $this->recordsetSelecting($this->CurrentFilter);
        $select = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlSelect() : $this->getQueryBuilder()->select("*");
        $groupBy = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlGroupBy() : "";
        $having = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlHaving() : "";
        $sql = $this->buildSelectSql($select, $this->getSqlFrom(), $this->getSqlWhere(), $groupBy, $having, "", $this->CurrentFilter, "");
        $cnt = $this->getRecordCount($sql);
        $this->CurrentFilter = $origFilter;
        return $cnt;
    }

    // Get record count (for current List page)
    public function listRecordCount()
    {
        $filter = $this->getSessionWhere();
        AddFilter($filter, $this->CurrentFilter);
        $filter = $this->applyUserIDFilters($filter);
        $this->recordsetSelecting($filter);
        $select = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlSelect() : $this->getQueryBuilder()->select("*");
        $groupBy = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlGroupBy() : "";
        $having = $this->TableType == 'CUSTOMVIEW' ? $this->getSqlHaving() : "";
        $sql = $this->buildSelectSql($select, $this->getSqlFrom(), $this->getSqlWhere(), $groupBy, $having, "", $filter, "");
        $cnt = $this->getRecordCount($sql);
        return $cnt;
    }

    /**
     * INSERT statement
     *
     * @param mixed $rs
     * @return QueryBuilder
     */
    protected function insertSql(&$rs)
    {
        $queryBuilder = $this->getQueryBuilder();
        $queryBuilder->insert($this->UpdateTable);
        foreach ($rs as $name => $value) {
            if (!isset($this->Fields[$name]) || $this->Fields[$name]->IsCustom) {
                continue;
            }
            $type = GetParameterType($this->Fields[$name], $value, $this->Dbid);
            $queryBuilder->setValue($this->Fields[$name]->Expression, $queryBuilder->createPositionalParameter($value, $type));
        }
        return $queryBuilder;
    }

    // Insert
    public function insert(&$rs)
    {
        $conn = $this->getConnection();
        $success = $this->insertSql($rs)->execute();
        if ($success) {
            // Get insert id if necessary
            $this->pd_id->setDbValue($conn->lastInsertId());
            $rs['pd_id'] = $this->pd_id->DbValue;
        }
        return $success;
    }

    /**
     * UPDATE statement
     *
     * @param array $rs Data to be updated
     * @param string|array $where WHERE clause
     * @param string $curfilter Filter
     * @return QueryBuilder
     */
    protected function updateSql(&$rs, $where = "", $curfilter = true)
    {
        $queryBuilder = $this->getQueryBuilder();
        $queryBuilder->update($this->UpdateTable);
        foreach ($rs as $name => $value) {
            if (!isset($this->Fields[$name]) || $this->Fields[$name]->IsCustom || $this->Fields[$name]->IsAutoIncrement) {
                continue;
            }
            $type = GetParameterType($this->Fields[$name], $value, $this->Dbid);
            $queryBuilder->set($this->Fields[$name]->Expression, $queryBuilder->createPositionalParameter($value, $type));
        }
        $filter = ($curfilter) ? $this->CurrentFilter : "";
        if (is_array($where)) {
            $where = $this->arrayToFilter($where);
        }
        AddFilter($filter, $where);
        if ($filter != "") {
            $queryBuilder->where($filter);
        }
        return $queryBuilder;
    }

    // Update
    public function update(&$rs, $where = "", $rsold = null, $curfilter = true)
    {
        // If no field is updated, execute may return 0. Treat as success
        $success = $this->updateSql($rs, $where, $curfilter)->execute();
        $success = ($success > 0) ? $success : true;
        return $success;
    }

    /**
     * DELETE statement
     *
     * @param array $rs Key values
     * @param string|array $where WHERE clause
     * @param string $curfilter Filter
     * @return QueryBuilder
     */
    protected function deleteSql(&$rs, $where = "", $curfilter = true)
    {
        $queryBuilder = $this->getQueryBuilder();
        $queryBuilder->delete($this->UpdateTable);
        if (is_array($where)) {
            $where = $this->arrayToFilter($where);
        }
        if ($rs) {
            if (array_key_exists('pd_id', $rs)) {
                AddFilter($where, QuotedName('pd_id', $this->Dbid) . '=' . QuotedValue($rs['pd_id'], $this->pd_id->DataType, $this->Dbid));
            }
        }
        $filter = ($curfilter) ? $this->CurrentFilter : "";
        AddFilter($filter, $where);
        return $queryBuilder->where($filter != "" ? $filter : "0=1");
    }

    // Delete
    public function delete(&$rs, $where = "", $curfilter = false)
    {
        $success = true;
        if ($success) {
            $success = $this->deleteSql($rs, $where, $curfilter)->execute();
        }
        return $success;
    }

    // Load DbValue from recordset or array
    protected function loadDbValues($row)
    {
        if (!is_array($row)) {
            return;
        }
        $this->pd_id->DbValue = $row['pd_id'];
        $this->kode_tapel->DbValue = $row['kode_tapel'];
        $this->kelas->DbValue = $row['kelas'];
        $this->nisn->DbValue = $row['nisn'];
        $this->nis->DbValue = $row['nis'];
        $this->nama->DbValue = $row['nama'];
        $this->jk->DbValue = $row['jk'];
        $this->tmp_lahir->DbValue = $row['tmp_lahir'];
        $this->tgl_lahir->DbValue = $row['tgl_lahir'];
        $this->agama->DbValue = $row['agama'];
        $this->status->DbValue = $row['status'];
        $this->anak_ke->DbValue = $row['anak_ke'];
        $this->alamat_siswa->DbValue = $row['alamat_siswa'];
        $this->no_hp->DbValue = $row['no_hp'];
        $this->sekolah_asal->DbValue = $row['sekolah_asal'];
        $this->diterima_di_kls->DbValue = $row['diterima_di_kls'];
        $this->tanggal->DbValue = $row['tanggal'];
        $this->nama_ayah->DbValue = $row['nama_ayah'];
        $this->nama_ibu->DbValue = $row['nama_ibu'];
        $this->alamat->DbValue = $row['alamat'];
        $this->telepon->DbValue = $row['telepon'];
        $this->kerja_ayah->DbValue = $row['kerja_ayah'];
        $this->kerja_ibu->DbValue = $row['kerja_ibu'];
        $this->nama_wali->DbValue = $row['nama_wali'];
        $this->no_telepon->DbValue = $row['no_telepon'];
        $this->alamat_wali->DbValue = $row['alamat_wali'];
        $this->kerja_wali->DbValue = $row['kerja_wali'];
    }

    // Delete uploaded files
    public function deleteUploadedFiles($row)
    {
        $this->loadDbValues($row);
    }

    // Record filter WHERE clause
    protected function sqlKeyFilter()
    {
        return "\"pd_id\" = @pd_id@";
    }

    // Get Key
    public function getKey($current = false)
    {
        $keys = [];
        $val = $current ? $this->pd_id->CurrentValue : $this->pd_id->OldValue;
        if (EmptyValue($val)) {
            return "";
        } else {
            $keys[] = $val;
        }
        return implode(Config("COMPOSITE_KEY_SEPARATOR"), $keys);
    }

    // Set Key
    public function setKey($key, $current = false)
    {
        $this->OldKey = strval($key);
        $keys = explode(Config("COMPOSITE_KEY_SEPARATOR"), $this->OldKey);
        if (count($keys) == 1) {
            if ($current) {
                $this->pd_id->CurrentValue = $keys[0];
            } else {
                $this->pd_id->OldValue = $keys[0];
            }
        }
    }

    // Get record filter
    public function getRecordFilter($row = null)
    {
        $keyFilter = $this->sqlKeyFilter();
        if (is_array($row)) {
            $val = array_key_exists('pd_id', $row) ? $row['pd_id'] : null;
        } else {
            $val = $this->pd_id->OldValue !== null ? $this->pd_id->OldValue : $this->pd_id->CurrentValue;
        }
        if (!is_numeric($val)) {
            return "0=1"; // Invalid key
        }
        if ($val === null) {
            return "0=1"; // Invalid key
        } else {
            $keyFilter = str_replace("@pd_id@", AdjustSql($val, $this->Dbid), $keyFilter); // Replace key value
        }
        return $keyFilter;
    }

    // Return page URL
    public function getReturnUrl()
    {
        $referUrl = ReferUrl();
        $referPageName = ReferPageName();
        $name = PROJECT_NAME . "_" . $this->TableVar . "_" . Config("TABLE_RETURN_URL");
        // Get referer URL automatically
        if ($referUrl != "" && $referPageName != CurrentPageName() && $referPageName != "login") { // Referer not same page or login page
            $_SESSION[$name] = $referUrl; // Save to Session
        }
        return $_SESSION[$name] ?? GetUrl("PesertaDidikList");
    }

    // Set return page URL
    public function setReturnUrl($v)
    {
        $_SESSION[PROJECT_NAME . "_" . $this->TableVar . "_" . Config("TABLE_RETURN_URL")] = $v;
    }

    // Get modal caption
    public function getModalCaption($pageName)
    {
        global $Language;
        if ($pageName == "PesertaDidikView") {
            return $Language->phrase("View");
        } elseif ($pageName == "PesertaDidikEdit") {
            return $Language->phrase("Edit");
        } elseif ($pageName == "PesertaDidikAdd") {
            return $Language->phrase("Add");
        } else {
            return "";
        }
    }

    // API page name
    public function getApiPageName($action)
    {
        switch (strtolower($action)) {
            case Config("API_VIEW_ACTION"):
                return "PesertaDidikView";
            case Config("API_ADD_ACTION"):
                return "PesertaDidikAdd";
            case Config("API_EDIT_ACTION"):
                return "PesertaDidikEdit";
            case Config("API_DELETE_ACTION"):
                return "PesertaDidikDelete";
            case Config("API_LIST_ACTION"):
                return "PesertaDidikList";
            default:
                return "";
        }
    }

    // List URL
    public function getListUrl()
    {
        return "PesertaDidikList";
    }

    // View URL
    public function getViewUrl($parm = "")
    {
        if ($parm != "") {
            $url = $this->keyUrl("PesertaDidikView", $this->getUrlParm($parm));
        } else {
            $url = $this->keyUrl("PesertaDidikView", $this->getUrlParm(Config("TABLE_SHOW_DETAIL") . "="));
        }
        return $this->addMasterUrl($url);
    }

    // Add URL
    public function getAddUrl($parm = "")
    {
        if ($parm != "") {
            $url = "PesertaDidikAdd?" . $this->getUrlParm($parm);
        } else {
            $url = "PesertaDidikAdd";
        }
        return $this->addMasterUrl($url);
    }

    // Edit URL
    public function getEditUrl($parm = "")
    {
        $url = $this->keyUrl("PesertaDidikEdit", $this->getUrlParm($parm));
        return $this->addMasterUrl($url);
    }

    // Inline edit URL
    public function getInlineEditUrl()
    {
        $url = $this->keyUrl(CurrentPageName(), $this->getUrlParm("action=edit"));
        return $this->addMasterUrl($url);
    }

    // Copy URL
    public function getCopyUrl($parm = "")
    {
        $url = $this->keyUrl("PesertaDidikAdd", $this->getUrlParm($parm));
        return $this->addMasterUrl($url);
    }

    // Inline copy URL
    public function getInlineCopyUrl()
    {
        $url = $this->keyUrl(CurrentPageName(), $this->getUrlParm("action=copy"));
        return $this->addMasterUrl($url);
    }

    // Delete URL
    public function getDeleteUrl()
    {
        return $this->keyUrl("PesertaDidikDelete", $this->getUrlParm());
    }

    // Add master url
    public function addMasterUrl($url)
    {
        return $url;
    }

    public function keyToJson($htmlEncode = false)
    {
        $json = "";
        $json .= "pd_id:" . JsonEncode($this->pd_id->CurrentValue, "number");
        $json = "{" . $json . "}";
        if ($htmlEncode) {
            $json = HtmlEncode($json);
        }
        return $json;
    }

    // Add key value to URL
    public function keyUrl($url, $parm = "")
    {
        if ($this->pd_id->CurrentValue !== null) {
            $url .= "/" . rawurlencode($this->pd_id->CurrentValue);
        } else {
            return "javascript:ew.alert(ew.language.phrase('InvalidRecord'));";
        }
        if ($parm != "") {
            $url .= "?" . $parm;
        }
        return $url;
    }

    // Render sort
    public function renderSort($fld)
    {
        $classId = $fld->TableVar . "_" . $fld->Param;
        $scriptId = str_replace("%id%", $classId, "tpc_%id%");
        $scriptStart = $this->UseCustomTemplate ? "<template id=\"" . $scriptId . "\">" : "";
        $scriptEnd = $this->UseCustomTemplate ? "</template>" : "";
        $jsSort = " class=\"ew-pointer\" onclick=\"ew.sort(event, '" . $this->sortUrl($fld) . "', 1);\"";
        if ($this->sortUrl($fld) == "") {
            $html = <<<NOSORTHTML
{$scriptStart}<div class="ew-table-header-caption">{$fld->caption()}</div>{$scriptEnd}
NOSORTHTML;
        } else {
            if ($fld->getSort() == "ASC") {
                $sortIcon = '<i class="fas fa-sort-up"></i>';
            } elseif ($fld->getSort() == "DESC") {
                $sortIcon = '<i class="fas fa-sort-down"></i>';
            } else {
                $sortIcon = '';
            }
            $html = <<<SORTHTML
{$scriptStart}<div{$jsSort}><div class="ew-table-header-btn"><span class="ew-table-header-caption">{$fld->caption()}</span><span class="ew-table-header-sort">{$sortIcon}</span></div></div>{$scriptEnd}
SORTHTML;
        }
        return $html;
    }

    // Sort URL
    public function sortUrl($fld)
    {
        if (
            $this->CurrentAction || $this->isExport() ||
            in_array($fld->Type, [141, 201, 203, 128, 204, 205])
        ) { // Unsortable data type
                return "";
        } elseif ($fld->Sortable) {
            $urlParm = $this->getUrlParm("order=" . urlencode($fld->Name) . "&amp;ordertype=" . $fld->getNextSort());
            return $this->addMasterUrl(CurrentPageName() . "?" . $urlParm);
        } else {
            return "";
        }
    }

    // Get record keys from Post/Get/Session
    public function getRecordKeys()
    {
        $arKeys = [];
        $arKey = [];
        if (Param("key_m") !== null) {
            $arKeys = Param("key_m");
            $cnt = count($arKeys);
        } else {
            if (($keyValue = Param("pd_id") ?? Route("pd_id")) !== null) {
                $arKeys[] = $keyValue;
            } elseif (IsApi() && (($keyValue = Key(0) ?? Route(2)) !== null)) {
                $arKeys[] = $keyValue;
            } else {
                $arKeys = null; // Do not setup
            }

            //return $arKeys; // Do not return yet, so the values will also be checked by the following code
        }
        // Check keys
        $ar = [];
        if (is_array($arKeys)) {
            foreach ($arKeys as $key) {
                if (!is_numeric($key)) {
                    continue;
                }
                $ar[] = $key;
            }
        }
        return $ar;
    }

    // Get filter from record keys
    public function getFilterFromRecordKeys($setCurrent = true)
    {
        $arKeys = $this->getRecordKeys();
        $keyFilter = "";
        foreach ($arKeys as $key) {
            if ($keyFilter != "") {
                $keyFilter .= " OR ";
            }
            if ($setCurrent) {
                $this->pd_id->CurrentValue = $key;
            } else {
                $this->pd_id->OldValue = $key;
            }
            $keyFilter .= "(" . $this->getRecordFilter() . ")";
        }
        return $keyFilter;
    }

    // Load recordset based on filter
    public function &loadRs($filter)
    {
        $sql = $this->getSql($filter); // Set up filter (WHERE Clause)
        $conn = $this->getConnection();
        $stmt = $conn->executeQuery($sql);
        return $stmt;
    }

    // Load row values from record
    public function loadListRowValues(&$rs)
    {
        if (is_array($rs)) {
            $row = $rs;
        } elseif ($rs && property_exists($rs, "fields")) { // Recordset
            $row = $rs->fields;
        } else {
            return;
        }
        $this->pd_id->setDbValue($row['pd_id']);
        $this->kode_tapel->setDbValue($row['kode_tapel']);
        $this->kelas->setDbValue($row['kelas']);
        $this->nisn->setDbValue($row['nisn']);
        $this->nis->setDbValue($row['nis']);
        $this->nama->setDbValue($row['nama']);
        $this->jk->setDbValue($row['jk']);
        $this->tmp_lahir->setDbValue($row['tmp_lahir']);
        $this->tgl_lahir->setDbValue($row['tgl_lahir']);
        $this->agama->setDbValue($row['agama']);
        $this->status->setDbValue($row['status']);
        $this->anak_ke->setDbValue($row['anak_ke']);
        $this->alamat_siswa->setDbValue($row['alamat_siswa']);
        $this->no_hp->setDbValue($row['no_hp']);
        $this->sekolah_asal->setDbValue($row['sekolah_asal']);
        $this->diterima_di_kls->setDbValue($row['diterima_di_kls']);
        $this->tanggal->setDbValue($row['tanggal']);
        $this->nama_ayah->setDbValue($row['nama_ayah']);
        $this->nama_ibu->setDbValue($row['nama_ibu']);
        $this->alamat->setDbValue($row['alamat']);
        $this->telepon->setDbValue($row['telepon']);
        $this->kerja_ayah->setDbValue($row['kerja_ayah']);
        $this->kerja_ibu->setDbValue($row['kerja_ibu']);
        $this->nama_wali->setDbValue($row['nama_wali']);
        $this->no_telepon->setDbValue($row['no_telepon']);
        $this->alamat_wali->setDbValue($row['alamat_wali']);
        $this->kerja_wali->setDbValue($row['kerja_wali']);
    }

    // Render list row values
    public function renderListRow()
    {
        global $Security, $CurrentLanguage, $Language;

        // Call Row Rendering event
        $this->rowRendering();

        // Common render codes

        // pd_id
        $this->pd_id->CellCssStyle = "white-space: nowrap;";

        // kode_tapel
        $this->kode_tapel->CellCssStyle = "white-space: nowrap;";

        // kelas
        $this->kelas->CellCssStyle = "white-space: nowrap;";

        // nisn
        $this->nisn->CellCssStyle = "white-space: nowrap;";

        // nis
        $this->nis->CellCssStyle = "white-space: nowrap;";

        // nama
        $this->nama->CellCssStyle = "white-space: nowrap;";

        // jk
        $this->jk->CellCssStyle = "white-space: nowrap;";

        // tmp_lahir
        $this->tmp_lahir->CellCssStyle = "white-space: nowrap;";

        // tgl_lahir
        $this->tgl_lahir->CellCssStyle = "white-space: nowrap;";

        // agama
        $this->agama->CellCssStyle = "white-space: nowrap;";

        // status
        $this->status->CellCssStyle = "white-space: nowrap;";

        // anak_ke
        $this->anak_ke->CellCssStyle = "white-space: nowrap;";

        // alamat_siswa
        $this->alamat_siswa->CellCssStyle = "white-space: nowrap;";

        // no_hp
        $this->no_hp->CellCssStyle = "white-space: nowrap;";

        // sekolah_asal
        $this->sekolah_asal->CellCssStyle = "white-space: nowrap;";

        // diterima_di_kls
        $this->diterima_di_kls->CellCssStyle = "white-space: nowrap;";

        // tanggal
        $this->tanggal->CellCssStyle = "white-space: nowrap;";

        // nama_ayah
        $this->nama_ayah->CellCssStyle = "white-space: nowrap;";

        // nama_ibu
        $this->nama_ibu->CellCssStyle = "white-space: nowrap;";

        // alamat
        $this->alamat->CellCssStyle = "white-space: nowrap;";

        // telepon
        $this->telepon->CellCssStyle = "white-space: nowrap;";

        // kerja_ayah
        $this->kerja_ayah->CellCssStyle = "white-space: nowrap;";

        // kerja_ibu
        $this->kerja_ibu->CellCssStyle = "white-space: nowrap;";

        // nama_wali
        $this->nama_wali->CellCssStyle = "white-space: nowrap;";

        // no_telepon
        $this->no_telepon->CellCssStyle = "white-space: nowrap;";

        // alamat_wali

        // kerja_wali

        // pd_id
        $this->pd_id->ViewValue = $this->pd_id->CurrentValue;
        $this->pd_id->ViewCustomAttributes = "";

        // kode_tapel
        $this->kode_tapel->ViewValue = $this->kode_tapel->CurrentValue;
        $this->kode_tapel->ViewCustomAttributes = "";

        // kelas
        $this->kelas->ViewValue = $this->kelas->CurrentValue;
        $this->kelas->ViewCustomAttributes = "";

        // nisn
        $this->nisn->ViewValue = $this->nisn->CurrentValue;
        $this->nisn->ViewCustomAttributes = "";

        // nis
        $this->nis->ViewValue = $this->nis->CurrentValue;
        $this->nis->ViewCustomAttributes = "";

        // nama
        $this->nama->ViewValue = $this->nama->CurrentValue;
        $this->nama->ViewCustomAttributes = "";

        // jk
        $this->jk->ViewValue = $this->jk->CurrentValue;
        $this->jk->ViewCustomAttributes = "";

        // tmp_lahir
        $this->tmp_lahir->ViewValue = $this->tmp_lahir->CurrentValue;
        $this->tmp_lahir->ViewCustomAttributes = "";

        // tgl_lahir
        $this->tgl_lahir->ViewValue = $this->tgl_lahir->CurrentValue;
        $this->tgl_lahir->ViewCustomAttributes = "";

        // agama
        $this->agama->ViewValue = $this->agama->CurrentValue;
        $this->agama->ViewCustomAttributes = "";

        // status
        $this->status->ViewValue = $this->status->CurrentValue;
        $this->status->ViewCustomAttributes = "";

        // anak_ke
        $this->anak_ke->ViewValue = $this->anak_ke->CurrentValue;
        $this->anak_ke->ViewCustomAttributes = "";

        // alamat_siswa
        $this->alamat_siswa->ViewValue = $this->alamat_siswa->CurrentValue;
        $this->alamat_siswa->ViewCustomAttributes = "";

        // no_hp
        $this->no_hp->ViewValue = $this->no_hp->CurrentValue;
        $this->no_hp->ViewCustomAttributes = "";

        // sekolah_asal
        $this->sekolah_asal->ViewValue = $this->sekolah_asal->CurrentValue;
        $this->sekolah_asal->ViewCustomAttributes = "";

        // diterima_di_kls
        $this->diterima_di_kls->ViewValue = $this->diterima_di_kls->CurrentValue;
        $this->diterima_di_kls->ViewCustomAttributes = "";

        // tanggal
        $this->tanggal->ViewValue = $this->tanggal->CurrentValue;
        $this->tanggal->ViewCustomAttributes = "";

        // nama_ayah
        $this->nama_ayah->ViewValue = $this->nama_ayah->CurrentValue;
        $this->nama_ayah->ViewCustomAttributes = "";

        // nama_ibu
        $this->nama_ibu->ViewValue = $this->nama_ibu->CurrentValue;
        $this->nama_ibu->ViewCustomAttributes = "";

        // alamat
        $this->alamat->ViewValue = $this->alamat->CurrentValue;
        $this->alamat->ViewCustomAttributes = "";

        // telepon
        $this->telepon->ViewValue = $this->telepon->CurrentValue;
        $this->telepon->ViewCustomAttributes = "";

        // kerja_ayah
        $this->kerja_ayah->ViewValue = $this->kerja_ayah->CurrentValue;
        $this->kerja_ayah->ViewCustomAttributes = "";

        // kerja_ibu
        $this->kerja_ibu->ViewValue = $this->kerja_ibu->CurrentValue;
        $this->kerja_ibu->ViewCustomAttributes = "";

        // nama_wali
        $this->nama_wali->ViewValue = $this->nama_wali->CurrentValue;
        $this->nama_wali->ViewCustomAttributes = "";

        // no_telepon
        $this->no_telepon->ViewValue = $this->no_telepon->CurrentValue;
        $this->no_telepon->ViewCustomAttributes = "";

        // alamat_wali
        $this->alamat_wali->ViewValue = $this->alamat_wali->CurrentValue;
        $this->alamat_wali->ViewCustomAttributes = "";

        // kerja_wali
        $this->kerja_wali->ViewValue = $this->kerja_wali->CurrentValue;
        $this->kerja_wali->ViewCustomAttributes = "";

        // pd_id
        $this->pd_id->LinkCustomAttributes = "";
        $this->pd_id->HrefValue = "";
        $this->pd_id->TooltipValue = "";

        // kode_tapel
        $this->kode_tapel->LinkCustomAttributes = "";
        $this->kode_tapel->HrefValue = "";
        $this->kode_tapel->TooltipValue = "";

        // kelas
        $this->kelas->LinkCustomAttributes = "";
        $this->kelas->HrefValue = "";
        $this->kelas->TooltipValue = "";

        // nisn
        $this->nisn->LinkCustomAttributes = "";
        $this->nisn->HrefValue = "";
        $this->nisn->TooltipValue = "";

        // nis
        $this->nis->LinkCustomAttributes = "";
        $this->nis->HrefValue = "";
        $this->nis->TooltipValue = "";

        // nama
        $this->nama->LinkCustomAttributes = "";
        $this->nama->HrefValue = "";
        $this->nama->TooltipValue = "";

        // jk
        $this->jk->LinkCustomAttributes = "";
        $this->jk->HrefValue = "";
        $this->jk->TooltipValue = "";

        // tmp_lahir
        $this->tmp_lahir->LinkCustomAttributes = "";
        $this->tmp_lahir->HrefValue = "";
        $this->tmp_lahir->TooltipValue = "";

        // tgl_lahir
        $this->tgl_lahir->LinkCustomAttributes = "";
        $this->tgl_lahir->HrefValue = "";
        $this->tgl_lahir->TooltipValue = "";

        // agama
        $this->agama->LinkCustomAttributes = "";
        $this->agama->HrefValue = "";
        $this->agama->TooltipValue = "";

        // status
        $this->status->LinkCustomAttributes = "";
        $this->status->HrefValue = "";
        $this->status->TooltipValue = "";

        // anak_ke
        $this->anak_ke->LinkCustomAttributes = "";
        $this->anak_ke->HrefValue = "";
        $this->anak_ke->TooltipValue = "";

        // alamat_siswa
        $this->alamat_siswa->LinkCustomAttributes = "";
        $this->alamat_siswa->HrefValue = "";
        $this->alamat_siswa->TooltipValue = "";

        // no_hp
        $this->no_hp->LinkCustomAttributes = "";
        $this->no_hp->HrefValue = "";
        $this->no_hp->TooltipValue = "";

        // sekolah_asal
        $this->sekolah_asal->LinkCustomAttributes = "";
        $this->sekolah_asal->HrefValue = "";
        $this->sekolah_asal->TooltipValue = "";

        // diterima_di_kls
        $this->diterima_di_kls->LinkCustomAttributes = "";
        $this->diterima_di_kls->HrefValue = "";
        $this->diterima_di_kls->TooltipValue = "";

        // tanggal
        $this->tanggal->LinkCustomAttributes = "";
        $this->tanggal->HrefValue = "";
        $this->tanggal->TooltipValue = "";

        // nama_ayah
        $this->nama_ayah->LinkCustomAttributes = "";
        $this->nama_ayah->HrefValue = "";
        $this->nama_ayah->TooltipValue = "";

        // nama_ibu
        $this->nama_ibu->LinkCustomAttributes = "";
        $this->nama_ibu->HrefValue = "";
        $this->nama_ibu->TooltipValue = "";

        // alamat
        $this->alamat->LinkCustomAttributes = "";
        $this->alamat->HrefValue = "";
        $this->alamat->TooltipValue = "";

        // telepon
        $this->telepon->LinkCustomAttributes = "";
        $this->telepon->HrefValue = "";
        $this->telepon->TooltipValue = "";

        // kerja_ayah
        $this->kerja_ayah->LinkCustomAttributes = "";
        $this->kerja_ayah->HrefValue = "";
        $this->kerja_ayah->TooltipValue = "";

        // kerja_ibu
        $this->kerja_ibu->LinkCustomAttributes = "";
        $this->kerja_ibu->HrefValue = "";
        $this->kerja_ibu->TooltipValue = "";

        // nama_wali
        $this->nama_wali->LinkCustomAttributes = "";
        $this->nama_wali->HrefValue = "";
        $this->nama_wali->TooltipValue = "";

        // no_telepon
        $this->no_telepon->LinkCustomAttributes = "";
        $this->no_telepon->HrefValue = "";
        $this->no_telepon->TooltipValue = "";

        // alamat_wali
        $this->alamat_wali->LinkCustomAttributes = "";
        $this->alamat_wali->HrefValue = "";
        $this->alamat_wali->TooltipValue = "";

        // kerja_wali
        $this->kerja_wali->LinkCustomAttributes = "";
        $this->kerja_wali->HrefValue = "";
        $this->kerja_wali->TooltipValue = "";

        // Call Row Rendered event
        $this->rowRendered();

        // Save data for Custom Template
        $this->Rows[] = $this->customTemplateFieldValues();
    }

    // Render edit row values
    public function renderEditRow()
    {
        global $Security, $CurrentLanguage, $Language;

        // Call Row Rendering event
        $this->rowRendering();

        // pd_id
        $this->pd_id->EditAttrs["class"] = "form-control";
        $this->pd_id->EditCustomAttributes = "";
        $this->pd_id->EditValue = $this->pd_id->CurrentValue;
        $this->pd_id->ViewCustomAttributes = "";

        // kode_tapel

        // kelas
        $this->kelas->EditAttrs["class"] = "form-control";
        $this->kelas->EditCustomAttributes = "";
        if (!$Security->isAdmin() && $Security->isLoggedIn() && !$this->userIDAllow("info")) { // Non system admin
            $this->kelas->CurrentValue = CurrentUserID();
            $this->kelas->EditValue = $this->kelas->CurrentValue;
            $this->kelas->ViewCustomAttributes = "";
        } else {
        }

        // nisn
        $this->nisn->EditAttrs["class"] = "form-control";
        $this->nisn->EditCustomAttributes = "";
        if (!$this->nisn->Raw) {
            $this->nisn->CurrentValue = HtmlDecode($this->nisn->CurrentValue);
        }
        $this->nisn->EditValue = $this->nisn->CurrentValue;

        // nis
        $this->nis->EditAttrs["class"] = "form-control";
        $this->nis->EditCustomAttributes = "";
        if (!$this->nis->Raw) {
            $this->nis->CurrentValue = HtmlDecode($this->nis->CurrentValue);
        }
        $this->nis->EditValue = $this->nis->CurrentValue;

        // nama
        $this->nama->EditAttrs["class"] = "form-control";
        $this->nama->EditCustomAttributes = "";
        if (!$this->nama->Raw) {
            $this->nama->CurrentValue = HtmlDecode($this->nama->CurrentValue);
        }
        $this->nama->EditValue = $this->nama->CurrentValue;

        // jk
        $this->jk->EditAttrs["class"] = "form-control";
        $this->jk->EditCustomAttributes = "";
        if (!$this->jk->Raw) {
            $this->jk->CurrentValue = HtmlDecode($this->jk->CurrentValue);
        }
        $this->jk->EditValue = $this->jk->CurrentValue;

        // tmp_lahir
        $this->tmp_lahir->EditAttrs["class"] = "form-control";
        $this->tmp_lahir->EditCustomAttributes = "";
        if (!$this->tmp_lahir->Raw) {
            $this->tmp_lahir->CurrentValue = HtmlDecode($this->tmp_lahir->CurrentValue);
        }
        $this->tmp_lahir->EditValue = $this->tmp_lahir->CurrentValue;

        // tgl_lahir
        $this->tgl_lahir->EditAttrs["class"] = "form-control";
        $this->tgl_lahir->EditCustomAttributes = "";
        if (!$this->tgl_lahir->Raw) {
            $this->tgl_lahir->CurrentValue = HtmlDecode($this->tgl_lahir->CurrentValue);
        }
        $this->tgl_lahir->EditValue = $this->tgl_lahir->CurrentValue;

        // agama
        $this->agama->EditAttrs["class"] = "form-control";
        $this->agama->EditCustomAttributes = "";
        if (!$this->agama->Raw) {
            $this->agama->CurrentValue = HtmlDecode($this->agama->CurrentValue);
        }
        $this->agama->EditValue = $this->agama->CurrentValue;

        // status
        $this->status->EditAttrs["class"] = "form-control";
        $this->status->EditCustomAttributes = "";
        if (!$this->status->Raw) {
            $this->status->CurrentValue = HtmlDecode($this->status->CurrentValue);
        }
        $this->status->EditValue = $this->status->CurrentValue;

        // anak_ke
        $this->anak_ke->EditAttrs["class"] = "form-control";
        $this->anak_ke->EditCustomAttributes = "";
        if (!$this->anak_ke->Raw) {
            $this->anak_ke->CurrentValue = HtmlDecode($this->anak_ke->CurrentValue);
        }
        $this->anak_ke->EditValue = $this->anak_ke->CurrentValue;

        // alamat_siswa
        $this->alamat_siswa->EditAttrs["class"] = "form-control";
        $this->alamat_siswa->EditCustomAttributes = "";
        if (!$this->alamat_siswa->Raw) {
            $this->alamat_siswa->CurrentValue = HtmlDecode($this->alamat_siswa->CurrentValue);
        }
        $this->alamat_siswa->EditValue = $this->alamat_siswa->CurrentValue;

        // no_hp
        $this->no_hp->EditAttrs["class"] = "form-control";
        $this->no_hp->EditCustomAttributes = "";
        if (!$this->no_hp->Raw) {
            $this->no_hp->CurrentValue = HtmlDecode($this->no_hp->CurrentValue);
        }
        $this->no_hp->EditValue = $this->no_hp->CurrentValue;

        // sekolah_asal
        $this->sekolah_asal->EditAttrs["class"] = "form-control";
        $this->sekolah_asal->EditCustomAttributes = "";
        if (!$this->sekolah_asal->Raw) {
            $this->sekolah_asal->CurrentValue = HtmlDecode($this->sekolah_asal->CurrentValue);
        }
        $this->sekolah_asal->EditValue = $this->sekolah_asal->CurrentValue;

        // diterima_di_kls
        $this->diterima_di_kls->EditAttrs["class"] = "form-control";
        $this->diterima_di_kls->EditCustomAttributes = "";
        if (!$this->diterima_di_kls->Raw) {
            $this->diterima_di_kls->CurrentValue = HtmlDecode($this->diterima_di_kls->CurrentValue);
        }
        $this->diterima_di_kls->EditValue = $this->diterima_di_kls->CurrentValue;

        // tanggal
        $this->tanggal->EditAttrs["class"] = "form-control";
        $this->tanggal->EditCustomAttributes = "";
        if (!$this->tanggal->Raw) {
            $this->tanggal->CurrentValue = HtmlDecode($this->tanggal->CurrentValue);
        }
        $this->tanggal->EditValue = $this->tanggal->CurrentValue;

        // nama_ayah
        $this->nama_ayah->EditAttrs["class"] = "form-control";
        $this->nama_ayah->EditCustomAttributes = "";
        if (!$this->nama_ayah->Raw) {
            $this->nama_ayah->CurrentValue = HtmlDecode($this->nama_ayah->CurrentValue);
        }
        $this->nama_ayah->EditValue = $this->nama_ayah->CurrentValue;

        // nama_ibu
        $this->nama_ibu->EditAttrs["class"] = "form-control";
        $this->nama_ibu->EditCustomAttributes = "";
        if (!$this->nama_ibu->Raw) {
            $this->nama_ibu->CurrentValue = HtmlDecode($this->nama_ibu->CurrentValue);
        }
        $this->nama_ibu->EditValue = $this->nama_ibu->CurrentValue;

        // alamat
        $this->alamat->EditAttrs["class"] = "form-control";
        $this->alamat->EditCustomAttributes = "";
        if (!$this->alamat->Raw) {
            $this->alamat->CurrentValue = HtmlDecode($this->alamat->CurrentValue);
        }
        $this->alamat->EditValue = $this->alamat->CurrentValue;

        // telepon
        $this->telepon->EditAttrs["class"] = "form-control";
        $this->telepon->EditCustomAttributes = "";
        if (!$this->telepon->Raw) {
            $this->telepon->CurrentValue = HtmlDecode($this->telepon->CurrentValue);
        }
        $this->telepon->EditValue = $this->telepon->CurrentValue;

        // kerja_ayah
        $this->kerja_ayah->EditAttrs["class"] = "form-control";
        $this->kerja_ayah->EditCustomAttributes = "";
        if (!$this->kerja_ayah->Raw) {
            $this->kerja_ayah->CurrentValue = HtmlDecode($this->kerja_ayah->CurrentValue);
        }
        $this->kerja_ayah->EditValue = $this->kerja_ayah->CurrentValue;

        // kerja_ibu
        $this->kerja_ibu->EditAttrs["class"] = "form-control";
        $this->kerja_ibu->EditCustomAttributes = "";
        if (!$this->kerja_ibu->Raw) {
            $this->kerja_ibu->CurrentValue = HtmlDecode($this->kerja_ibu->CurrentValue);
        }
        $this->kerja_ibu->EditValue = $this->kerja_ibu->CurrentValue;

        // nama_wali
        $this->nama_wali->EditAttrs["class"] = "form-control";
        $this->nama_wali->EditCustomAttributes = "";
        if (!$this->nama_wali->Raw) {
            $this->nama_wali->CurrentValue = HtmlDecode($this->nama_wali->CurrentValue);
        }
        $this->nama_wali->EditValue = $this->nama_wali->CurrentValue;

        // no_telepon
        $this->no_telepon->EditAttrs["class"] = "form-control";
        $this->no_telepon->EditCustomAttributes = "";
        if (!$this->no_telepon->Raw) {
            $this->no_telepon->CurrentValue = HtmlDecode($this->no_telepon->CurrentValue);
        }
        $this->no_telepon->EditValue = $this->no_telepon->CurrentValue;

        // alamat_wali
        $this->alamat_wali->EditAttrs["class"] = "form-control";
        $this->alamat_wali->EditCustomAttributes = "";
        if (!$this->alamat_wali->Raw) {
            $this->alamat_wali->CurrentValue = HtmlDecode($this->alamat_wali->CurrentValue);
        }
        $this->alamat_wali->EditValue = $this->alamat_wali->CurrentValue;

        // kerja_wali
        $this->kerja_wali->EditAttrs["class"] = "form-control";
        $this->kerja_wali->EditCustomAttributes = "";
        if (!$this->kerja_wali->Raw) {
            $this->kerja_wali->CurrentValue = HtmlDecode($this->kerja_wali->CurrentValue);
        }
        $this->kerja_wali->EditValue = $this->kerja_wali->CurrentValue;

        // Call Row Rendered event
        $this->rowRendered();
    }

    // Aggregate list row values
    public function aggregateListRowValues()
    {
    }

    // Aggregate list row (for rendering)
    public function aggregateListRow()
    {
        // Call Row Rendered event
        $this->rowRendered();
    }

    // Export data in HTML/CSV/Word/Excel/Email/PDF format
    public function exportDocument($doc, $recordset, $startRec = 1, $stopRec = 1, $exportPageType = "")
    {
        if (!$recordset || !$doc) {
            return;
        }
        if (!$doc->ExportCustom) {
            // Write header
            $doc->exportTableHeader();
            if ($doc->Horizontal) { // Horizontal format, write header
                $doc->beginExportRow();
                if ($exportPageType == "view") {
                    $doc->exportCaption($this->pd_id);
                    $doc->exportCaption($this->kode_tapel);
                    $doc->exportCaption($this->kelas);
                    $doc->exportCaption($this->nisn);
                    $doc->exportCaption($this->nis);
                    $doc->exportCaption($this->nama);
                    $doc->exportCaption($this->jk);
                    $doc->exportCaption($this->tmp_lahir);
                    $doc->exportCaption($this->tgl_lahir);
                    $doc->exportCaption($this->agama);
                    $doc->exportCaption($this->status);
                    $doc->exportCaption($this->anak_ke);
                    $doc->exportCaption($this->alamat_siswa);
                    $doc->exportCaption($this->no_hp);
                    $doc->exportCaption($this->sekolah_asal);
                    $doc->exportCaption($this->diterima_di_kls);
                    $doc->exportCaption($this->tanggal);
                    $doc->exportCaption($this->nama_ayah);
                    $doc->exportCaption($this->nama_ibu);
                    $doc->exportCaption($this->alamat);
                    $doc->exportCaption($this->telepon);
                    $doc->exportCaption($this->kerja_ayah);
                    $doc->exportCaption($this->kerja_ibu);
                    $doc->exportCaption($this->nama_wali);
                    $doc->exportCaption($this->no_telepon);
                    $doc->exportCaption($this->alamat_wali);
                    $doc->exportCaption($this->kerja_wali);
                } else {
                    $doc->exportCaption($this->kode_tapel);
                    $doc->exportCaption($this->kelas);
                    $doc->exportCaption($this->nisn);
                    $doc->exportCaption($this->nis);
                    $doc->exportCaption($this->nama);
                    $doc->exportCaption($this->jk);
                    $doc->exportCaption($this->tmp_lahir);
                    $doc->exportCaption($this->tgl_lahir);
                    $doc->exportCaption($this->agama);
                    $doc->exportCaption($this->status);
                    $doc->exportCaption($this->anak_ke);
                    $doc->exportCaption($this->alamat_siswa);
                    $doc->exportCaption($this->no_hp);
                    $doc->exportCaption($this->sekolah_asal);
                    $doc->exportCaption($this->diterima_di_kls);
                    $doc->exportCaption($this->tanggal);
                    $doc->exportCaption($this->nama_ayah);
                    $doc->exportCaption($this->nama_ibu);
                    $doc->exportCaption($this->alamat);
                    $doc->exportCaption($this->telepon);
                    $doc->exportCaption($this->kerja_ayah);
                    $doc->exportCaption($this->kerja_ibu);
                    $doc->exportCaption($this->nama_wali);
                    $doc->exportCaption($this->no_telepon);
                    $doc->exportCaption($this->alamat_wali);
                    $doc->exportCaption($this->kerja_wali);
                }
                $doc->endExportRow();
            }
        }

        // Move to first record
        $recCnt = $startRec - 1;
        $stopRec = ($stopRec > 0) ? $stopRec : PHP_INT_MAX;
        while (!$recordset->EOF && $recCnt < $stopRec) {
            $row = $recordset->fields;
            $recCnt++;
            if ($recCnt >= $startRec) {
                $rowCnt = $recCnt - $startRec + 1;

                // Page break
                if ($this->ExportPageBreakCount > 0) {
                    if ($rowCnt > 1 && ($rowCnt - 1) % $this->ExportPageBreakCount == 0) {
                        $doc->exportPageBreak();
                    }
                }
                $this->loadListRowValues($row);

                // Render row
                $this->RowType = ROWTYPE_VIEW; // Render view
                $this->resetAttributes();
                $this->renderListRow();
                if (!$doc->ExportCustom) {
                    $doc->beginExportRow($rowCnt); // Allow CSS styles if enabled
                    if ($exportPageType == "view") {
                        $doc->exportField($this->pd_id);
                        $doc->exportField($this->kode_tapel);
                        $doc->exportField($this->kelas);
                        $doc->exportField($this->nisn);
                        $doc->exportField($this->nis);
                        $doc->exportField($this->nama);
                        $doc->exportField($this->jk);
                        $doc->exportField($this->tmp_lahir);
                        $doc->exportField($this->tgl_lahir);
                        $doc->exportField($this->agama);
                        $doc->exportField($this->status);
                        $doc->exportField($this->anak_ke);
                        $doc->exportField($this->alamat_siswa);
                        $doc->exportField($this->no_hp);
                        $doc->exportField($this->sekolah_asal);
                        $doc->exportField($this->diterima_di_kls);
                        $doc->exportField($this->tanggal);
                        $doc->exportField($this->nama_ayah);
                        $doc->exportField($this->nama_ibu);
                        $doc->exportField($this->alamat);
                        $doc->exportField($this->telepon);
                        $doc->exportField($this->kerja_ayah);
                        $doc->exportField($this->kerja_ibu);
                        $doc->exportField($this->nama_wali);
                        $doc->exportField($this->no_telepon);
                        $doc->exportField($this->alamat_wali);
                        $doc->exportField($this->kerja_wali);
                    } else {
                        $doc->exportField($this->kode_tapel);
                        $doc->exportField($this->kelas);
                        $doc->exportField($this->nisn);
                        $doc->exportField($this->nis);
                        $doc->exportField($this->nama);
                        $doc->exportField($this->jk);
                        $doc->exportField($this->tmp_lahir);
                        $doc->exportField($this->tgl_lahir);
                        $doc->exportField($this->agama);
                        $doc->exportField($this->status);
                        $doc->exportField($this->anak_ke);
                        $doc->exportField($this->alamat_siswa);
                        $doc->exportField($this->no_hp);
                        $doc->exportField($this->sekolah_asal);
                        $doc->exportField($this->diterima_di_kls);
                        $doc->exportField($this->tanggal);
                        $doc->exportField($this->nama_ayah);
                        $doc->exportField($this->nama_ibu);
                        $doc->exportField($this->alamat);
                        $doc->exportField($this->telepon);
                        $doc->exportField($this->kerja_ayah);
                        $doc->exportField($this->kerja_ibu);
                        $doc->exportField($this->nama_wali);
                        $doc->exportField($this->no_telepon);
                        $doc->exportField($this->alamat_wali);
                        $doc->exportField($this->kerja_wali);
                    }
                    $doc->endExportRow($rowCnt);
                }
            }

            // Call Row Export server event
            if ($doc->ExportCustom) {
                $this->rowExport($row);
            }
            $recordset->moveNext();
        }
        if (!$doc->ExportCustom) {
            $doc->exportTableFooter();
        }
    }

    // Add User ID filter
    public function addUserIDFilter($filter = "")
    {
        global $Security;
        $filterWrk = "";
        $id = (CurrentPageID() == "list") ? $this->CurrentAction : CurrentPageID();
        if (!$this->userIDAllow($id) && !$Security->isAdmin()) {
            $filterWrk = $Security->userIdList();
            if ($filterWrk != "") {
                $filterWrk = '"kelas" IN (' . $filterWrk . ')';
            }
        }

        // Call User ID Filtering event
        $this->userIdFiltering($filterWrk);
        AddFilter($filter, $filterWrk);
        return $filter;
    }

    // User ID subquery
    public function getUserIDSubquery(&$fld, &$masterfld)
    {
        global $UserTable;
        $wrk = "";
        $sql = "SELECT " . $masterfld->Expression . " FROM \"peserta_didik\"";
        $filter = $this->addUserIDFilter("");
        if ($filter != "") {
            $sql .= " WHERE " . $filter;
        }

        // List all values
        if ($rs = Conn($UserTable->Dbid)->executeQuery($sql)->fetchAll(\PDO::FETCH_NUM)) {
            foreach ($rs as $row) {
                if ($wrk != "") {
                    $wrk .= ",";
                }
                $wrk .= QuotedValue($row[0], $masterfld->DataType, Config("USER_TABLE_DBID"));
            }
        }
        if ($wrk != "") {
            $wrk = $fld->Expression . " IN (" . $wrk . ")";
        } else { // No User ID value found
            $wrk = "0=1";
        }
        return $wrk;
    }

    // Get file data
    public function getFileData($fldparm, $key, $resize, $width = 0, $height = 0, $plugins = [])
    {
        // No binary fields
        return false;
    }

    // Table level events

    // Recordset Selecting event
    public function recordsetSelecting(&$filter)
    {
        // Enter your code here
    }

    // Recordset Selected event
    public function recordsetSelected(&$rs)
    {
        //Log("Recordset Selected");
    }

    // Recordset Search Validated event
    public function recordsetSearchValidated()
    {
        // Example:
        //$this->MyField1->AdvancedSearch->SearchValue = "your search criteria"; // Search value
    }

    // Recordset Searching event
    public function recordsetSearching(&$filter)
    {
        // Enter your code here
    }

    // Row_Selecting event
    public function rowSelecting(&$filter)
    {
        // Enter your code here
    }

    // Row Selected event
    public function rowSelected(&$rs)
    {
        //Log("Row Selected");
    }

    // Row Inserting event
    public function rowInserting($rsold, &$rsnew)
    {
        // Enter your code here
        // To cancel, set return value to false
        return true;
    }

    // Row Inserted event
    public function rowInserted($rsold, &$rsnew)
    {
        //Log("Row Inserted");
    }

    // Row Updating event
    public function rowUpdating($rsold, &$rsnew)
    {
        // Enter your code here
        // To cancel, set return value to false
        return true;
    }

    // Row Updated event
    public function rowUpdated($rsold, &$rsnew)
    {
        //Log("Row Updated");
    }

    // Row Update Conflict event
    public function rowUpdateConflict($rsold, &$rsnew)
    {
        // Enter your code here
        // To ignore conflict, set return value to false
        return true;
    }

    // Grid Inserting event
    public function gridInserting()
    {
        // Enter your code here
        // To reject grid insert, set return value to false
        return true;
    }

    // Grid Inserted event
    public function gridInserted($rsnew)
    {
        //Log("Grid Inserted");
    }

    // Grid Updating event
    public function gridUpdating($rsold)
    {
        // Enter your code here
        // To reject grid update, set return value to false
        return true;
    }

    // Grid Updated event
    public function gridUpdated($rsold, $rsnew)
    {
        //Log("Grid Updated");
    }

    // Row Deleting event
    public function rowDeleting(&$rs)
    {
        // Enter your code here
        // To cancel, set return value to False
        return true;
    }

    // Row Deleted event
    public function rowDeleted(&$rs)
    {
        //Log("Row Deleted");
    }

    // Email Sending event
    public function emailSending($email, &$args)
    {
        //var_dump($email); var_dump($args); exit();
        return true;
    }

    // Lookup Selecting event
    public function lookupSelecting($fld, &$filter)
    {
        //var_dump($fld->Name, $fld->Lookup, $filter); // Uncomment to view the filter
        // Enter your code here
    }

    // Row Rendering event
    public function rowRendering()
    {
        // Enter your code here
    }

    // Row Rendered event
    public function rowRendered()
    {
        // To view properties of field class, use:
        //var_dump($this-><FieldName>);
    }

    // User ID Filtering event
    public function userIdFiltering(&$filter)
    {
        // Enter your code here
    }
}
