<?php

namespace ProjectManagement\prjProjectManagement;

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

    // Form object
    let form = new ew.FormBuilder()
        .setId("fprojecttemplatepaymentprocessadd")
        .setPageId("add")

        // Add fields
        .setFields([
            ["DocumentName", [fields.DocumentName.visible && fields.DocumentName.required ? ew.Validators.required(fields.DocumentName.caption) : null], fields.DocumentName.isInvalid],
            ["PICClient", [fields.PICClient.visible && fields.PICClient.required ? ew.Validators.required(fields.PICClient.caption) : null], fields.PICClient.isInvalid],
            ["FileName", [fields.FileName.visible && fields.FileName.required ? ew.Validators.fileRequired(fields.FileName.caption) : null], fields.FileName.isInvalid],
            ["Description", [fields.Description.visible && fields.Description.required ? ew.Validators.required(fields.Description.caption) : null], fields.Description.isInvalid],
            ["templateid", [fields.templateid.visible && fields.templateid.required ? ew.Validators.required(fields.templateid.caption) : null], fields.templateid.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({
            "PICClient": <?= $Page->PICClient->toClientList($Page) ?>,
            "templateid": <?= $Page->templateid->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="fprojecttemplatepaymentprocessadd" id="fprojecttemplatepaymentprocessadd" 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="projecttemplatepaymentprocess">
<input type="hidden" name="action" id="action" value="insert">
<input type="hidden" name="modal" value="<?= (int)$Page->IsModal ?>">
<?php if (IsJsonResponse()) { ?>
<input type="hidden" name="json" value="1">
<?php } ?>
<input type="hidden" name="<?= $Page->OldKeyName ?>" value="<?= $Page->OldKey ?>">
<?php if ($Page->getCurrentMasterTable() == "projecttemplate") { ?>
<input type="hidden" name="<?= Config("TABLE_SHOW_MASTER") ?>" value="projecttemplate">
<input type="hidden" name="fk_ID" value="<?= HtmlEncode($Page->templateid->getSessionValue()) ?>">
<?php } ?>
<div class="ew-add-div"><!-- page* -->
<?php if ($Page->DocumentName->Visible) { // DocumentName ?>
    <div id="r_DocumentName"<?= $Page->DocumentName->rowAttributes() ?>>
        <label id="elh_projecttemplatepaymentprocess_DocumentName" for="x_DocumentName" class="<?= $Page->LeftColumnClass ?>"><?= $Page->DocumentName->caption() ?><?= $Page->DocumentName->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->DocumentName->cellAttributes() ?>>
<span id="el_projecttemplatepaymentprocess_DocumentName">
<input type="<?= $Page->DocumentName->getInputTextType() ?>" name="x_DocumentName" id="x_DocumentName" data-table="projecttemplatepaymentprocess" 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->PICClient->Visible) { // PICClient ?>
    <div id="r_PICClient"<?= $Page->PICClient->rowAttributes() ?>>
        <label id="elh_projecttemplatepaymentprocess_PICClient" for="x_PICClient" class="<?= $Page->LeftColumnClass ?>"><?= $Page->PICClient->caption() ?><?= $Page->PICClient->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->PICClient->cellAttributes() ?>>
<span id="el_projecttemplatepaymentprocess_PICClient">
    <select
        id="x_PICClient"
        name="x_PICClient"
        class="form-select ew-select<?= $Page->PICClient->isInvalidClass() ?>"
        <?php if (!$Page->PICClient->IsNativeSelect) { ?>
        data-select2-id="fprojecttemplatepaymentprocessadd_x_PICClient"
        <?php } ?>
        data-table="projecttemplatepaymentprocess"
        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("fprojecttemplatepaymentprocessadd", function() {
    var options = { name: "x_PICClient", selectId: "fprojecttemplatepaymentprocessadd_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 (fprojecttemplatepaymentprocessadd.lists.PICClient?.lookupOptions.length) {
        options.data = { id: "x_PICClient", form: "fprojecttemplatepaymentprocessadd" };
    } else {
        options.ajax = { id: "x_PICClient", form: "fprojecttemplatepaymentprocessadd", limit: ew.LOOKUP_PAGE_SIZE };
    }
    options.minimumInputLength = ew.selectMinimumInputLength;
    options = Object.assign({}, ew.selectOptions, options, ew.vars.tables.projecttemplatepaymentprocess.fields.PICClient.selectOptions);
    ew.createSelect(options);
});
</script>
<?php } ?>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->FileName->Visible) { // FileName ?>
    <div id="r_FileName"<?= $Page->FileName->rowAttributes() ?>>
        <label id="elh_projecttemplatepaymentprocess_FileName" class="<?= $Page->LeftColumnClass ?>"><?= $Page->FileName->caption() ?><?= $Page->FileName->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->FileName->cellAttributes() ?>>
<span id="el_projecttemplatepaymentprocess_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="projecttemplatepaymentprocess"
        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="0">
<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->Description->Visible) { // Description ?>
    <div id="r_Description"<?= $Page->Description->rowAttributes() ?>>
        <label id="elh_projecttemplatepaymentprocess_Description" class="<?= $Page->LeftColumnClass ?>"><?= $Page->Description->caption() ?><?= $Page->Description->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->Description->cellAttributes() ?>>
<span id="el_projecttemplatepaymentprocess_Description">
<?php $Page->Description->EditAttrs->appendClass("editor"); ?>
<textarea data-table="projecttemplatepaymentprocess" data-field="x_Description" name="x_Description" id="x_Description" cols="35" rows="4" placeholder="<?= HtmlEncode($Page->Description->getPlaceHolder()) ?>"<?= $Page->Description->editAttributes() ?> aria-describedby="x_Description_help"><?= $Page->Description->EditValue ?></textarea>
<?= $Page->Description->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->Description->getErrorMessage() ?></div>
<script>
loadjs.ready(["fprojecttemplatepaymentprocessadd", "editor"], function() {
    ew.createEditor("fprojecttemplatepaymentprocessadd", "x_Description", 0, 0, <?= $Page->Description->ReadOnly || false ? "true" : "false" ?>);
});
</script>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->templateid->Visible) { // templateid ?>
    <div id="r_templateid"<?= $Page->templateid->rowAttributes() ?>>
        <label id="elh_projecttemplatepaymentprocess_templateid" for="x_templateid" class="<?= $Page->LeftColumnClass ?>"><?= $Page->templateid->caption() ?><?= $Page->templateid->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->templateid->cellAttributes() ?>>
<?php if ($Page->templateid->getSessionValue() != "") { ?>
<span<?= $Page->templateid->viewAttributes() ?>>
<span class="form-control-plaintext"><?= $Page->templateid->getDisplayValue($Page->templateid->ViewValue) ?></span></span>
<input type="hidden" id="x_templateid" name="x_templateid" value="<?= HtmlEncode($Page->templateid->CurrentValue) ?>" data-hidden="1">
<?php } else { ?>
<span id="el_projecttemplatepaymentprocess_templateid">
<div class="input-group flex-nowrap">
    <select
        id="x_templateid"
        name="x_templateid"
        class="form-select ew-select<?= $Page->templateid->isInvalidClass() ?>"
        <?php if (!$Page->templateid->IsNativeSelect) { ?>
        data-select2-id="fprojecttemplatepaymentprocessadd_x_templateid"
        <?php } ?>
        data-table="projecttemplatepaymentprocess"
        data-field="x_templateid"
        data-value-separator="<?= $Page->templateid->displayValueSeparatorAttribute() ?>"
        data-placeholder="<?= HtmlEncode($Page->templateid->getPlaceHolder()) ?>"
        <?= $Page->templateid->editAttributes() ?>>
        <?= $Page->templateid->selectOptionListHtml("x_templateid") ?>
    </select>
    <?php if (AllowAdd(CurrentProjectID() . "projecttemplate") && !$Page->templateid->ReadOnly) { ?>
    <button type="button" class="btn btn-default ew-add-opt-btn" id="aol_x_templateid" title="<?= HtmlTitle($Language->phrase("AddLink")) . "&nbsp;" . $Page->templateid->caption() ?>" data-title="<?= $Page->templateid->caption() ?>" data-ew-action="add-option" data-el="x_templateid" data-url="<?= GetUrl("projecttemplateaddopt") ?>"><i class="fa-solid fa-plus ew-icon"></i></button>
    <?php } ?>
</div>
<?= $Page->templateid->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->templateid->getErrorMessage() ?></div>
<?= $Page->templateid->Lookup->getParamTag($Page, "p_x_templateid") ?>
<?php if (!$Page->templateid->IsNativeSelect) { ?>
<script>
loadjs.ready("fprojecttemplatepaymentprocessadd", function() {
    var options = { name: "x_templateid", selectId: "fprojecttemplatepaymentprocessadd_x_templateid" },
        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 (fprojecttemplatepaymentprocessadd.lists.templateid?.lookupOptions.length) {
        options.data = { id: "x_templateid", form: "fprojecttemplatepaymentprocessadd" };
    } else {
        options.ajax = { id: "x_templateid", form: "fprojecttemplatepaymentprocessadd", limit: ew.LOOKUP_PAGE_SIZE };
    }
    options.minimumInputLength = ew.selectMinimumInputLength;
    options = Object.assign({}, ew.selectOptions, options, ew.vars.tables.projecttemplatepaymentprocess.fields.templateid.selectOptions);
    ew.createSelect(options);
});
</script>
<?php } ?>
</span>
<?php } ?>
</div></div>
    </div>
<?php } ?>
    <span id="el_projecttemplatepaymentprocess_Created_Date">
    <input type="hidden" data-table="projecttemplatepaymentprocess" data-field="x_Created_Date" data-hidden="1" name="x_Created_Date" id="x_Created_Date" value="<?= HtmlEncode($Page->Created_Date->CurrentValue) ?>">
    </span>
    <span id="el_projecttemplatepaymentprocess_Created_By">
    <input type="hidden" data-table="projecttemplatepaymentprocess" data-field="x_Created_By" data-hidden="1" name="x_Created_By" id="x_Created_By" value="<?= HtmlEncode($Page->Created_By->CurrentValue) ?>">
    </span>
</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="fprojecttemplatepaymentprocessadd"><?= $Language->phrase("AddBtn") ?></button>
<?php if (IsJsonResponse()) { ?>
<button class="btn btn-default ew-btn" name="btn-cancel" id="btn-cancel" type="button" data-bs-dismiss="modal"><?= $Language->phrase("CancelBtn") ?></button>
<?php } else { ?>
<button class="btn btn-default ew-btn" name="btn-cancel" id="btn-cancel" type="button" form="fprojecttemplatepaymentprocessadd" data-href="<?= HtmlEncode(GetUrl($Page->getReturnUrl())) ?>"><?= $Language->phrase("CancelBtn") ?></button>
<?php } ?>
    </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("projecttemplatepaymentprocess");
});
</script>
<script>
loadjs.ready("load", function () {
    // Write your table-specific startup script here, no need to add script tags.
});
</script>
