<?php

namespace ProjectManagement\prjProjectManagement;

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

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

        // Add fields
        .setFields([
            ["template_name", [fields.template_name.visible && fields.template_name.required ? ew.Validators.required(fields.template_name.caption) : null], fields.template_name.isInvalid],
            ["description", [fields.description.visible && fields.description.required ? ew.Validators.required(fields.description.caption) : null], fields.description.isInvalid],
            ["Active", [fields.Active.visible && fields.Active.required ? ew.Validators.required(fields.Active.caption) : null], fields.Active.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({
            "Active": <?= $Page->Active->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="fprojecttemplateadd" id="fprojecttemplateadd" 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="projecttemplate">
<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 ?>">
<div class="ew-add-div"><!-- page* -->
<?php if ($Page->template_name->Visible) { // template_name ?>
    <div id="r_template_name"<?= $Page->template_name->rowAttributes() ?>>
        <label id="elh_projecttemplate_template_name" for="x_template_name" class="<?= $Page->LeftColumnClass ?>"><?= $Page->template_name->caption() ?><?= $Page->template_name->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->template_name->cellAttributes() ?>>
<span id="el_projecttemplate_template_name">
<input type="<?= $Page->template_name->getInputTextType() ?>" name="x_template_name" id="x_template_name" data-table="projecttemplate" data-field="x_template_name" value="<?= $Page->template_name->EditValue ?>" maxlength="150" placeholder="<?= HtmlEncode($Page->template_name->getPlaceHolder()) ?>" data-format-pattern="<?= HtmlEncode($Page->template_name->formatPattern()) ?>"<?= $Page->template_name->editAttributes() ?> aria-describedby="x_template_name_help">
<?= $Page->template_name->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->template_name->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->description->Visible) { // description ?>
    <div id="r_description"<?= $Page->description->rowAttributes() ?>>
        <label id="elh_projecttemplate_description" for="x_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_projecttemplate_description">
<textarea data-table="projecttemplate" 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>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->Active->Visible) { // Active ?>
    <div id="r_Active"<?= $Page->Active->rowAttributes() ?>>
        <label id="elh_projecttemplate_Active" class="<?= $Page->LeftColumnClass ?>"><?= $Page->Active->caption() ?><?= $Page->Active->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->Active->cellAttributes() ?>>
<span id="el_projecttemplate_Active">
<div class="form-check d-inline-block">
    <input type="checkbox" class="form-check-input<?= $Page->Active->isInvalidClass() ?>" data-table="projecttemplate" data-field="x_Active" data-boolean name="x_Active" id="x_Active" value="1"<?= ConvertToBool($Page->Active->CurrentValue) ? " checked" : "" ?><?= $Page->Active->editAttributes() ?> aria-describedby="x_Active_help">
    <div class="invalid-feedback"><?= $Page->Active->getErrorMessage() ?></div>
</div>
<?= $Page->Active->getCustomMessage() ?>
</span>
</div></div>
    </div>
<?php } ?>
    <span id="el_projecttemplate_Created_Date">
    <input type="hidden" data-table="projecttemplate" 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_projecttemplate_Created_By">
    <input type="hidden" data-table="projecttemplate" 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* -->
<?php if ($Page->getCurrentDetailTable() != "") { ?>
<?php
    $Page->DetailPages->ValidKeys = explode(",", $Page->getCurrentDetailTable());
?>
<div class="ew-detail-pages"><!-- detail-pages -->
<div class="ew-nav<?= $Page->DetailPages->containerClasses() ?>" id="details_Page"><!-- tabs -->
    <ul class="<?= $Page->DetailPages->navClasses() ?>" role="tablist"><!-- .nav -->
<?php
    if (in_array("projecttemplateresult", explode(",", $Page->getCurrentDetailTable())) && $projecttemplateresult->DetailAdd) {
?>
        <li class="nav-item"><button class="<?= $Page->DetailPages->navLinkClasses("projecttemplateresult") ?><?= $Page->DetailPages->activeClasses("projecttemplateresult") ?>" data-bs-target="#tab_projecttemplateresult" data-bs-toggle="tab" type="button" role="tab" aria-controls="tab_projecttemplateresult" aria-selected="<?= JsonEncode($Page->DetailPages->isActive("projecttemplateresult")) ?>"><?= $Language->tablePhrase("projecttemplateresult", "TblCaption") ?></button></li>
<?php
    }
?>
<?php
    if (in_array("projecttemplatepaymentprocess", explode(",", $Page->getCurrentDetailTable())) && $projecttemplatepaymentprocess->DetailAdd) {
?>
        <li class="nav-item"><button class="<?= $Page->DetailPages->navLinkClasses("projecttemplatepaymentprocess") ?><?= $Page->DetailPages->activeClasses("projecttemplatepaymentprocess") ?>" data-bs-target="#tab_projecttemplatepaymentprocess" data-bs-toggle="tab" type="button" role="tab" aria-controls="tab_projecttemplatepaymentprocess" aria-selected="<?= JsonEncode($Page->DetailPages->isActive("projecttemplatepaymentprocess")) ?>"><?= $Language->tablePhrase("projecttemplatepaymentprocess", "TblCaption") ?></button></li>
<?php
    }
?>
    </ul><!-- /.nav -->
    <div class="<?= $Page->DetailPages->tabContentClasses() ?>"><!-- .tab-content -->
<?php
    if (in_array("projecttemplateresult", explode(",", $Page->getCurrentDetailTable())) && $projecttemplateresult->DetailAdd) {
?>
        <div class="<?= $Page->DetailPages->tabPaneClasses("projecttemplateresult") ?><?= $Page->DetailPages->activeClasses("projecttemplateresult") ?>" id="tab_projecttemplateresult" role="tabpanel"><!-- page* -->
<?php include_once "ProjecttemplateresultGrid.php" ?>
        </div><!-- /page* -->
<?php } ?>
<?php
    if (in_array("projecttemplatepaymentprocess", explode(",", $Page->getCurrentDetailTable())) && $projecttemplatepaymentprocess->DetailAdd) {
?>
        <div class="<?= $Page->DetailPages->tabPaneClasses("projecttemplatepaymentprocess") ?><?= $Page->DetailPages->activeClasses("projecttemplatepaymentprocess") ?>" id="tab_projecttemplatepaymentprocess" role="tabpanel"><!-- page* -->
<?php include_once "ProjecttemplatepaymentprocessGrid.php" ?>
        </div><!-- /page* -->
<?php } ?>
    </div><!-- /.tab-content -->
</div><!-- /tabs -->
</div><!-- /detail-pages -->
<?php } ?>
<?= $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="fprojecttemplateadd"><?= $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="fprojecttemplateadd" 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("projecttemplate");
});
</script>
<script>
loadjs.ready("load", function () {
    // Write your table-specific startup script here, no need to add script tags.
});
</script>
