<?php

namespace ProjectManagement\prjProjectManagement;

// Page object
$ProjectpaymentprocessUpdate = &$Page;
?>
<script>
var currentTable = <?= JsonEncode($Page->toClientVar()) ?>;
ew.deepAssign(ew.vars, { tables: { projectpaymentprocess: currentTable } });
var currentPageID = ew.PAGE_ID = "update";
var currentForm;
var fprojectpaymentprocessupdate;
loadjs.ready(["wrapper", "head"], function () {
    let $ = jQuery;
    let fields = currentTable.fields;

    // Form object
    let form = new ew.FormBuilder()
        .setId("fprojectpaymentprocessupdate")
        .setPageId("update")

        // Add fields
        .setFields([
            ["DocumentName", [fields.DocumentName.visible && fields.DocumentName.required ? ew.Validators.required(fields.DocumentName.caption) : null], fields.DocumentName.isInvalid],
            ["FileName", [fields.FileName.visible && fields.FileName.required ? ew.Validators.fileRequired(fields.FileName.caption) : null], fields.FileName.isInvalid],
            ["Completed", [fields.Completed.visible && fields.Completed.required ? ew.Validators.required(fields.Completed.caption) : null], fields.Completed.isInvalid],
            ["DateDelivered", [fields.DateDelivered.visible && fields.DateDelivered.required ? ew.Validators.required(fields.DateDelivered.caption) : null, ew.Validators.datetime(fields.DateDelivered.clientFormatPattern), ew.Validators.selected], fields.DateDelivered.isInvalid],
            ["PICClient", [fields.PICClient.visible && fields.PICClient.required ? ew.Validators.required(fields.PICClient.caption) : null], fields.PICClient.isInvalid],
            ["Remark", [fields.Remark.visible && fields.Remark.required ? ew.Validators.required(fields.Remark.caption) : null], fields.Remark.isInvalid],
            ["_ProjectID", [fields._ProjectID.visible && fields._ProjectID.required ? ew.Validators.required(fields._ProjectID.caption) : null], fields._ProjectID.isInvalid],
            ["Created_Date", [fields.Created_Date.visible && fields.Created_Date.required ? ew.Validators.required(fields.Created_Date.caption) : null], fields.Created_Date.isInvalid],
            ["Created_By", [fields.Created_By.visible && fields.Created_By.required ? ew.Validators.required(fields.Created_By.caption) : null], fields.Created_By.isInvalid],
            ["Last_Updated_Date", [fields.Last_Updated_Date.visible && fields.Last_Updated_Date.required ? ew.Validators.required(fields.Last_Updated_Date.caption) : null], fields.Last_Updated_Date.isInvalid],
            ["Last_Updated_By", [fields.Last_Updated_By.visible && fields.Last_Updated_By.required ? ew.Validators.required(fields.Last_Updated_By.caption) : null], fields.Last_Updated_By.isInvalid]
        ])

        // Form_CustomValidate
        .setCustomValidate(
            function (fobj) { // DO NOT CHANGE THIS LINE! (except for adding "async" keyword)!
                    // Your custom validation code here, return false if invalid.
                    return true;
                }
        )

        // Use JavaScript validation or not
        .setValidateRequired(ew.CLIENT_VALIDATE)

        // Dynamic selection lists
        .setLists({
            "Completed": <?= $Page->Completed->toClientList($Page) ?>,
            "PICClient": <?= $Page->PICClient->toClientList($Page) ?>,
            "_ProjectID": <?= $Page->_ProjectID->toClientList($Page) ?>,
        })
        .build();
    window[form.id] = form;
    currentForm = form;
    loadjs.done(form.id);
});
</script>
<script>
loadjs.ready("head", function () {
    // Write your table-specific client script here, no need to add script tags.
});
</script>
<?php $Page->showPageHeader(); ?>
<?php
$Page->showMessage();
?>
<form name="fprojectpaymentprocessupdate" id="fprojectpaymentprocessupdate" class="<?= $Page->FormClassName ?>" action="<?= CurrentPageUrl(false) ?>" method="post" autocomplete="off">
<?php if (Config("CHECK_TOKEN")) { ?>
<input type="hidden" name="<?= $TokenNameKey ?>" value="<?= $TokenName ?>"><!-- CSRF token name -->
<input type="hidden" name="<?= $TokenValueKey ?>" value="<?= $TokenValue ?>"><!-- CSRF token value -->
<?php } ?>
<input type="hidden" name="t" value="projectpaymentprocess">
<input type="hidden" name="action" id="action" value="update">
<input type="hidden" name="modal" value="<?= (int)$Page->IsModal ?>">
<?php foreach ($Page->RecKeys as $key) { ?>
<?php $keyvalue = is_array($key) ? implode(Config("COMPOSITE_KEY_SEPARATOR"), $key) : $key; ?>
<input type="hidden" name="key_m[]" value="<?= HtmlEncode($keyvalue) ?>">
<?php } ?>
<div id="tbl_projectpaymentprocessupdate" class="ew-update-div"><!-- page -->
    <?php if (!$Page->isConfirm()) { // Confirm page ?>
    <div class="form-check">
        <input type="checkbox" class="form-check-input" name="u" id="u" data-ew-action="select-all"><label class="form-check-label" for="u"><?= $Language->phrase("SelectAll") ?></label>
    </div>
    <?php } ?>
<?php if ($Page->DocumentName->Visible && (!$Page->isConfirm() || $Page->DocumentName->multiUpdateSelected())) { // DocumentName ?>
    <div id="r_DocumentName"<?= $Page->DocumentName->rowAttributes() ?>>
        <label for="x_DocumentName" class="<?= $Page->LeftColumnClass ?>">
            <div class="form-check">
                <input type="checkbox" name="u_DocumentName" id="u_DocumentName" class="form-check-input ew-multi-select" value="1"<?= $Page->DocumentName->multiUpdateSelected() ? " checked" : "" ?>>
                <label class="form-check-label" for="u_DocumentName"><?= $Page->DocumentName->caption() ?></label>
            </div>
        </label>
        <div class="<?= $Page->RightColumnClass ?>">
            <div<?= $Page->DocumentName->cellAttributes() ?>>
                <span id="el_projectpaymentprocess_DocumentName">
                <input type="<?= $Page->DocumentName->getInputTextType() ?>" name="x_DocumentName" id="x_DocumentName" data-table="projectpaymentprocess" data-field="x_DocumentName" value="<?= $Page->DocumentName->EditValue ?>" size="30" maxlength="100" placeholder="<?= HtmlEncode($Page->DocumentName->getPlaceHolder()) ?>" data-format-pattern="<?= HtmlEncode($Page->DocumentName->formatPattern()) ?>"<?= $Page->DocumentName->editAttributes() ?> aria-describedby="x_DocumentName_help">
                <?= $Page->DocumentName->getCustomMessage() ?>
                <div class="invalid-feedback"><?= $Page->DocumentName->getErrorMessage() ?></div>
                </span>
            </div>
        </div>
    </div>
<?php } ?>
<?php if ($Page->FileName->Visible && (!$Page->isConfirm() || $Page->FileName->multiUpdateSelected())) { // FileName ?>
    <div id="r_FileName"<?= $Page->FileName->rowAttributes() ?>>
        <label class="<?= $Page->LeftColumnClass ?>">
            <div class="form-check">
                <input type="checkbox" name="u_FileName" id="u_FileName" class="form-check-input ew-multi-select" value="1"<?= $Page->FileName->multiUpdateSelected() ? " checked" : "" ?>>
                <label class="form-check-label" for="u_FileName"><?= $Page->FileName->caption() ?></label>
            </div>
        </label>
        <div class="<?= $Page->RightColumnClass ?>">
            <div<?= $Page->FileName->cellAttributes() ?>>
                <span id="el_projectpaymentprocess_FileName">
                <div id="fd_x_FileName" class="fileinput-button ew-file-drop-zone">
                    <input
                        type="file"
                        id="x_FileName"
                        name="x_FileName"
                        class="form-control ew-file-input"
                        title="<?= $Page->FileName->title() ?>"
                        lang="<?= CurrentLanguageID() ?>"
                        data-table="projectpaymentprocess"
                        data-field="x_FileName"
                        data-size="500"
                        data-accept-file-types="<?= $Page->FileName->acceptFileTypes() ?>"
                        data-max-file-size="<?= $Page->FileName->UploadMaxFileSize ?>"
                        data-max-number-of-files="null"
                        data-disable-image-crop="<?= $Page->FileName->ImageCropper ? 0 : 1 ?>"
                        aria-describedby="x_FileName_help"
                        <?= ($Page->FileName->ReadOnly || $Page->FileName->Disabled) ? " disabled" : "" ?>
                        <?= $Page->FileName->editAttributes() ?>
                    >
                    <div class="text-body-secondary ew-file-text"><?= $Language->phrase("ChooseFile") ?></div>
                    <?= $Page->FileName->getCustomMessage() ?>
                    <div class="invalid-feedback"><?= $Page->FileName->getErrorMessage() ?></div>
                </div>
                <input type="hidden" name="fn_x_FileName" id= "fn_x_FileName" value="<?= $Page->FileName->Upload->FileName ?>">
                <input type="hidden" name="fa_x_FileName" id= "fa_x_FileName" value="<?= (Post("fa_x_FileName") == "0") ? "0" : "1" ?>">
                <table id="ft_x_FileName" class="table table-sm float-start ew-upload-table"><tbody class="files"></tbody></table>
                </span>
            </div>
        </div>
    </div>
<?php } ?>
<?php if ($Page->Completed->Visible && (!$Page->isConfirm() || $Page->Completed->multiUpdateSelected())) { // Completed ?>
    <div id="r_Completed"<?= $Page->Completed->rowAttributes() ?>>
        <label class="<?= $Page->LeftColumnClass ?>">
            <div class="form-check">
                <input type="checkbox" name="u_Completed" id="u_Completed" class="form-check-input ew-multi-select" value="1"<?= $Page->Completed->multiUpdateSelected() ? " checked" : "" ?>>
                <label class="form-check-label" for="u_Completed"><?= $Page->Completed->caption() ?></label>
            </div>
        </label>
        <div class="<?= $Page->RightColumnClass ?>">
            <div<?= $Page->Completed->cellAttributes() ?>>
                <span id="el_projectpaymentprocess_Completed">
                <div class="form-check d-inline-block">
                    <input type="checkbox" class="form-check-input<?= $Page->Completed->isInvalidClass() ?>" data-table="projectpaymentprocess" data-field="x_Completed" data-boolean name="x_Completed" id="x_Completed" value="1"<?= ConvertToBool($Page->Completed->CurrentValue) ? " checked" : "" ?><?= $Page->Completed->editAttributes() ?> aria-describedby="x_Completed_help">
                    <div class="invalid-feedback"><?= $Page->Completed->getErrorMessage() ?></div>
                </div>
                <?= $Page->Completed->getCustomMessage() ?>
                </span>
            </div>
        </div>
    </div>
<?php } ?>
<?php if ($Page->DateDelivered->Visible && (!$Page->isConfirm() || $Page->DateDelivered->multiUpdateSelected())) { // DateDelivered ?>
    <div id="r_DateDelivered"<?= $Page->DateDelivered->rowAttributes() ?>>
        <label for="x_DateDelivered" class="<?= $Page->LeftColumnClass ?>">
            <div class="form-check">
                <input type="checkbox" name="u_DateDelivered" id="u_DateDelivered" class="form-check-input ew-multi-select" value="1"<?= $Page->DateDelivered->multiUpdateSelected() ? " checked" : "" ?>>
                <label class="form-check-label" for="u_DateDelivered"><?= $Page->DateDelivered->caption() ?></label>
            </div>
        </label>
        <div class="<?= $Page->RightColumnClass ?>">
            <div<?= $Page->DateDelivered->cellAttributes() ?>>
                <span id="el_projectpaymentprocess_DateDelivered">
                <input type="<?= $Page->DateDelivered->getInputTextType() ?>" name="x_DateDelivered" id="x_DateDelivered" data-table="projectpaymentprocess" data-field="x_DateDelivered" value="<?= $Page->DateDelivered->EditValue ?>" placeholder="<?= HtmlEncode($Page->DateDelivered->getPlaceHolder()) ?>" data-format-pattern="<?= HtmlEncode($Page->DateDelivered->formatPattern()) ?>"<?= $Page->DateDelivered->editAttributes() ?> aria-describedby="x_DateDelivered_help">
                <?= $Page->DateDelivered->getCustomMessage() ?>
                <div class="invalid-feedback"><?= $Page->DateDelivered->getErrorMessage() ?></div>
                <?php if (!$Page->DateDelivered->ReadOnly && !$Page->DateDelivered->Disabled && !isset($Page->DateDelivered->EditAttrs["readonly"]) && !isset($Page->DateDelivered->EditAttrs["disabled"])) { ?>
                <script>
                loadjs.ready(["fprojectpaymentprocessupdate", "datetimepicker"], function () {
                    let format = "<?= DateFormat(5) ?>",
                        options = {
                            localization: {
                                locale: ew.LANGUAGE_ID + "-u-nu-" + ew.getNumberingSystem(),
                                hourCycle: format.match(/H/) ? "h24" : "h12",
                                format,
                                ...ew.language.phrase("datetimepicker")
                            },
                            display: {
                                icons: {
                                    previous: ew.IS_RTL ? "fa-solid fa-chevron-right" : "fa-solid fa-chevron-left",
                                    next: ew.IS_RTL ? "fa-solid fa-chevron-left" : "fa-solid fa-chevron-right"
                                },
                                components: {
                                    hours: !!format.match(/h/i),
                                    minutes: !!format.match(/m/),
                                    seconds: !!format.match(/s/i)
                                },
                                theme: ew.getPreferredTheme()
                            }
                        };
                    ew.createDateTimePicker("fprojectpaymentprocessupdate", "x_DateDelivered", ew.deepAssign({"useCurrent":false,"display":{"sideBySide":false}}, options));
                });
                </script>
                <?php } ?>
                </span>
            </div>
        </div>
    </div>
<?php } ?>
<?php if ($Page->PICClient->Visible && (!$Page->isConfirm() || $Page->PICClient->multiUpdateSelected())) { // PICClient ?>
    <div id="r_PICClient"<?= $Page->PICClient->rowAttributes() ?>>
        <label for="x_PICClient" class="<?= $Page->LeftColumnClass ?>">
            <div class="form-check">
                <input type="checkbox" name="u_PICClient" id="u_PICClient" class="form-check-input ew-multi-select" value="1"<?= $Page->PICClient->multiUpdateSelected() ? " checked" : "" ?>>
                <label class="form-check-label" for="u_PICClient"><?= $Page->PICClient->caption() ?></label>
            </div>
        </label>
        <div class="<?= $Page->RightColumnClass ?>">
            <div<?= $Page->PICClient->cellAttributes() ?>>
                <span id="el_projectpaymentprocess_PICClient">
                    <select
                        id="x_PICClient"
                        name="x_PICClient"
                        class="form-select ew-select<?= $Page->PICClient->isInvalidClass() ?>"
                        <?php if (!$Page->PICClient->IsNativeSelect) { ?>
                        data-select2-id="fprojectpaymentprocessupdate_x_PICClient"
                        <?php } ?>
                        data-table="projectpaymentprocess"
                        data-field="x_PICClient"
                        data-value-separator="<?= $Page->PICClient->displayValueSeparatorAttribute() ?>"
                        data-placeholder="<?= HtmlEncode($Page->PICClient->getPlaceHolder()) ?>"
                        <?= $Page->PICClient->editAttributes() ?>>
                        <?= $Page->PICClient->selectOptionListHtml("x_PICClient") ?>
                    </select>
                    <?= $Page->PICClient->getCustomMessage() ?>
                    <div class="invalid-feedback"><?= $Page->PICClient->getErrorMessage() ?></div>
                <?= $Page->PICClient->Lookup->getParamTag($Page, "p_x_PICClient") ?>
                <?php if (!$Page->PICClient->IsNativeSelect) { ?>
                <script>
                loadjs.ready("fprojectpaymentprocessupdate", function() {
                    var options = { name: "x_PICClient", selectId: "fprojectpaymentprocessupdate_x_PICClient" },
                        el = document.querySelector("select[data-select2-id='" + options.selectId + "']");
                    if (!el)
                        return;
                    options.closeOnSelect = !options.multiple;
                    options.dropdownParent = el.closest("#ew-modal-dialog, #ew-add-opt-dialog");
                    if (fprojectpaymentprocessupdate.lists.PICClient?.lookupOptions.length) {
                        options.data = { id: "x_PICClient", form: "fprojectpaymentprocessupdate" };
                    } else {
                        options.ajax = { id: "x_PICClient", form: "fprojectpaymentprocessupdate", limit: ew.LOOKUP_PAGE_SIZE };
                    }
                    options.minimumInputLength = ew.selectMinimumInputLength;
                    options = Object.assign({}, ew.selectOptions, options, ew.vars.tables.projectpaymentprocess.fields.PICClient.selectOptions);
                    ew.createSelect(options);
                });
                </script>
                <?php } ?>
                </span>
            </div>
        </div>
    </div>
<?php } ?>
<?php if ($Page->Remark->Visible && (!$Page->isConfirm() || $Page->Remark->multiUpdateSelected())) { // Remark ?>
    <div id="r_Remark"<?= $Page->Remark->rowAttributes() ?>>
        <label class="<?= $Page->LeftColumnClass ?>">
            <div class="form-check">
                <input type="checkbox" name="u_Remark" id="u_Remark" class="form-check-input ew-multi-select" value="1"<?= $Page->Remark->multiUpdateSelected() ? " checked" : "" ?>>
                <label class="form-check-label" for="u_Remark"><?= $Page->Remark->caption() ?></label>
            </div>
        </label>
        <div class="<?= $Page->RightColumnClass ?>">
            <div<?= $Page->Remark->cellAttributes() ?>>
                <span id="el_projectpaymentprocess_Remark">
                <?php $Page->Remark->EditAttrs->appendClass("editor"); ?>
                <textarea data-table="projectpaymentprocess" data-field="x_Remark" name="x_Remark" id="x_Remark" cols="35" rows="4" placeholder="<?= HtmlEncode($Page->Remark->getPlaceHolder()) ?>"<?= $Page->Remark->editAttributes() ?> aria-describedby="x_Remark_help"><?= $Page->Remark->EditValue ?></textarea>
                <?= $Page->Remark->getCustomMessage() ?>
                <div class="invalid-feedback"><?= $Page->Remark->getErrorMessage() ?></div>
                <script>
                loadjs.ready(["fprojectpaymentprocessupdate", "editor"], function() {
                    ew.createEditor("fprojectpaymentprocessupdate", "x_Remark", 0, 0, <?= $Page->Remark->ReadOnly || false ? "true" : "false" ?>);
                });
                </script>
                </span>
            </div>
        </div>
    </div>
<?php } ?>
<?php if ($Page->_ProjectID->Visible && (!$Page->isConfirm() || $Page->_ProjectID->multiUpdateSelected())) { // ProjectID ?>
    <div id="r__ProjectID"<?= $Page->_ProjectID->rowAttributes() ?>>
        <label for="x__ProjectID" class="<?= $Page->LeftColumnClass ?>">
            <div class="form-check">
                <input type="checkbox" name="u__ProjectID" id="u__ProjectID" class="form-check-input ew-multi-select" value="1"<?= $Page->_ProjectID->multiUpdateSelected() ? " checked" : "" ?>>
                <label class="form-check-label" for="u__ProjectID"><?= $Page->_ProjectID->caption() ?></label>
            </div>
        </label>
        <div class="<?= $Page->RightColumnClass ?>">
            <div<?= $Page->_ProjectID->cellAttributes() ?>>
                <?php if ($Page->_ProjectID->getSessionValue() != "") { ?>
                <span<?= $Page->_ProjectID->viewAttributes() ?>>
                <span class="form-control-plaintext"><?= $Page->_ProjectID->getDisplayValue($Page->_ProjectID->ViewValue) ?></span></span>
                <input type="hidden" id="x__ProjectID" name="x__ProjectID" value="<?= HtmlEncode($Page->_ProjectID->CurrentValue) ?>" data-hidden="1">
                <?php } else { ?>
                <span id="el_projectpaymentprocess__ProjectID">
                    <select
                        id="x__ProjectID"
                        name="x__ProjectID"
                        class="form-select ew-select<?= $Page->_ProjectID->isInvalidClass() ?>"
                        <?php if (!$Page->_ProjectID->IsNativeSelect) { ?>
                        data-select2-id="fprojectpaymentprocessupdate_x__ProjectID"
                        <?php } ?>
                        data-table="projectpaymentprocess"
                        data-field="x__ProjectID"
                        data-value-separator="<?= $Page->_ProjectID->displayValueSeparatorAttribute() ?>"
                        data-placeholder="<?= HtmlEncode($Page->_ProjectID->getPlaceHolder()) ?>"
                        <?= $Page->_ProjectID->editAttributes() ?>>
                        <?= $Page->_ProjectID->selectOptionListHtml("x__ProjectID") ?>
                    </select>
                    <?= $Page->_ProjectID->getCustomMessage() ?>
                    <div class="invalid-feedback"><?= $Page->_ProjectID->getErrorMessage() ?></div>
                <?= $Page->_ProjectID->Lookup->getParamTag($Page, "p_x__ProjectID") ?>
                <?php if (!$Page->_ProjectID->IsNativeSelect) { ?>
                <script>
                loadjs.ready("fprojectpaymentprocessupdate", function() {
                    var options = { name: "x__ProjectID", selectId: "fprojectpaymentprocessupdate_x__ProjectID" },
                        el = document.querySelector("select[data-select2-id='" + options.selectId + "']");
                    if (!el)
                        return;
                    options.closeOnSelect = !options.multiple;
                    options.dropdownParent = el.closest("#ew-modal-dialog, #ew-add-opt-dialog");
                    if (fprojectpaymentprocessupdate.lists._ProjectID?.lookupOptions.length) {
                        options.data = { id: "x__ProjectID", form: "fprojectpaymentprocessupdate" };
                    } else {
                        options.ajax = { id: "x__ProjectID", form: "fprojectpaymentprocessupdate", limit: ew.LOOKUP_PAGE_SIZE };
                    }
                    options.minimumInputLength = ew.selectMinimumInputLength;
                    options = Object.assign({}, ew.selectOptions, options, ew.vars.tables.projectpaymentprocess.fields._ProjectID.selectOptions);
                    ew.createSelect(options);
                });
                </script>
                <?php } ?>
                </span>
                <?php } ?>
            </div>
        </div>
    </div>
<?php } ?>
</div><!-- /page -->
<?= $Page->IsModal ? '<template class="ew-modal-buttons">' : '<div class="row ew-buttons">' ?><!-- buttons .row -->
    <div class="<?= $Page->OffsetColumnClass ?>"><!-- buttons offset -->
<button class="btn btn-primary ew-btn" name="btn-action" id="btn-action" type="submit" form="fprojectpaymentprocessupdate"><?= $Language->phrase("UpdateBtn") ?></button>
<button class="btn btn-default ew-btn" name="btn-cancel" id="btn-cancel" type="button" form="fprojectpaymentprocessupdate" data-href="<?= HtmlEncode(GetUrl($Page->getReturnUrl())) ?>"><?= $Language->phrase("CancelBtn") ?></button>
    </div><!-- /buttons offset -->
<?= $Page->IsModal ? "</template>" : "</div>" ?><!-- /buttons .row -->
</form>
<?php
$Page->showPageFooter();
echo GetDebugMessage();
?>
<script>
// Field event handlers
loadjs.ready("head", function() {
    ew.addEventHandlers("projectpaymentprocess");
});
</script>
<script>
loadjs.ready("load", function () {
    // Write your table-specific startup script here, no need to add script tags.
});
</script>
