<?php

namespace PHPMaker2024\laundrytech;

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

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

        // Add fields
        .setFields([
            ["articlename1", [fields.articlename1.visible && fields.articlename1.required ? ew.Validators.required(fields.articlename1.caption) : null], fields.articlename1.isInvalid],
            ["articlename2", [fields.articlename2.visible && fields.articlename2.required ? ew.Validators.required(fields.articlename2.caption) : null], fields.articlename2.isInvalid],
            ["categoryid", [fields.categoryid.visible && fields.categoryid.required ? ew.Validators.required(fields.categoryid.caption) : null, ew.Validators.integer], fields.categoryid.isInvalid],
            ["weight", [fields.weight.visible && fields.weight.required ? ew.Validators.required(fields.weight.caption) : null, ew.Validators.float], fields.weight.isInvalid],
            ["owned", [fields.owned.visible && fields.owned.required ? ew.Validators.required(fields.owned.caption) : null, ew.Validators.integer], fields.owned.isInvalid],
            ["customerId", [fields.customerId.visible && fields.customerId.required ? ew.Validators.required(fields.customerId.caption) : null, ew.Validators.integer], fields.customerId.isInvalid],
            ["siteId", [fields.siteId.visible && fields.siteId.required ? ew.Validators.required(fields.siteId.caption) : null, ew.Validators.integer], fields.siteId.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({
            "categoryid": <?= $Page->categoryid->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="farticlesadd" id="farticlesadd" class="<?= $Page->FormClassName ?>" action="<?= CurrentPageUrl(false) ?>" method="post" novalidate 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="articles">
<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->articlename1->Visible) { // articlename1 ?>
    <div id="r_articlename1"<?= $Page->articlename1->rowAttributes() ?>>
        <label id="elh_articles_articlename1" for="x_articlename1" class="<?= $Page->LeftColumnClass ?>"><?= $Page->articlename1->caption() ?><?= $Page->articlename1->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->articlename1->cellAttributes() ?>>
<span id="el_articles_articlename1">
<input type="<?= $Page->articlename1->getInputTextType() ?>" name="x_articlename1" id="x_articlename1" data-table="articles" data-field="x_articlename1" value="<?= $Page->articlename1->EditValue ?>" size="30" maxlength="255" placeholder="<?= HtmlEncode($Page->articlename1->getPlaceHolder()) ?>" data-format-pattern="<?= HtmlEncode($Page->articlename1->formatPattern()) ?>"<?= $Page->articlename1->editAttributes() ?> aria-describedby="x_articlename1_help">
<?= $Page->articlename1->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->articlename1->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->articlename2->Visible) { // articlename2 ?>
    <div id="r_articlename2"<?= $Page->articlename2->rowAttributes() ?>>
        <label id="elh_articles_articlename2" for="x_articlename2" class="<?= $Page->LeftColumnClass ?>"><?= $Page->articlename2->caption() ?><?= $Page->articlename2->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->articlename2->cellAttributes() ?>>
<span id="el_articles_articlename2">
<input type="<?= $Page->articlename2->getInputTextType() ?>" name="x_articlename2" id="x_articlename2" data-table="articles" data-field="x_articlename2" value="<?= $Page->articlename2->EditValue ?>" size="30" maxlength="255" placeholder="<?= HtmlEncode($Page->articlename2->getPlaceHolder()) ?>" data-format-pattern="<?= HtmlEncode($Page->articlename2->formatPattern()) ?>"<?= $Page->articlename2->editAttributes() ?> aria-describedby="x_articlename2_help">
<?= $Page->articlename2->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->articlename2->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->categoryid->Visible) { // categoryid ?>
    <div id="r_categoryid"<?= $Page->categoryid->rowAttributes() ?>>
        <label id="elh_articles_categoryid" class="<?= $Page->LeftColumnClass ?>"><?= $Page->categoryid->caption() ?><?= $Page->categoryid->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->categoryid->cellAttributes() ?>>
<span id="el_articles_categoryid">
<?php
if (IsRTL()) {
    $Page->categoryid->EditAttrs["dir"] = "rtl";
}
?>
<span id="as_x_categoryid" class="ew-auto-suggest">
    <input type="<?= $Page->categoryid->getInputTextType() ?>" class="form-control" name="sv_x_categoryid" id="sv_x_categoryid" value="<?= RemoveHtml($Page->categoryid->EditValue) ?>" autocomplete="off" size="30" placeholder="<?= HtmlEncode($Page->categoryid->getPlaceHolder()) ?>" data-placeholder="<?= HtmlEncode($Page->categoryid->getPlaceHolder()) ?>" data-format-pattern="<?= HtmlEncode($Page->categoryid->formatPattern()) ?>"<?= $Page->categoryid->editAttributes() ?> aria-describedby="x_categoryid_help">
</span>
<selection-list hidden class="form-control" data-table="articles" data-field="x_categoryid" data-input="sv_x_categoryid" data-value-separator="<?= $Page->categoryid->displayValueSeparatorAttribute() ?>" name="x_categoryid" id="x_categoryid" value="<?= HtmlEncode($Page->categoryid->CurrentValue) ?>"></selection-list>
<?= $Page->categoryid->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->categoryid->getErrorMessage() ?></div>
<script>
loadjs.ready("farticlesadd", function() {
    farticlesadd.createAutoSuggest(Object.assign({"id":"x_categoryid","forceSelect":false}, { lookupAllDisplayFields: <?= $Page->categoryid->Lookup->LookupAllDisplayFields ? "true" : "false" ?> }, ew.vars.tables.articles.fields.categoryid.autoSuggestOptions));
});
</script>
<?= $Page->categoryid->Lookup->getParamTag($Page, "p_x_categoryid") ?>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->weight->Visible) { // weight ?>
    <div id="r_weight"<?= $Page->weight->rowAttributes() ?>>
        <label id="elh_articles_weight" for="x_weight" class="<?= $Page->LeftColumnClass ?>"><?= $Page->weight->caption() ?><?= $Page->weight->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->weight->cellAttributes() ?>>
<span id="el_articles_weight">
<input type="<?= $Page->weight->getInputTextType() ?>" name="x_weight" id="x_weight" data-table="articles" data-field="x_weight" value="<?= $Page->weight->EditValue ?>" size="30" placeholder="<?= HtmlEncode($Page->weight->getPlaceHolder()) ?>" data-format-pattern="<?= HtmlEncode($Page->weight->formatPattern()) ?>"<?= $Page->weight->editAttributes() ?> aria-describedby="x_weight_help">
<?= $Page->weight->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->weight->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->owned->Visible) { // owned ?>
    <div id="r_owned"<?= $Page->owned->rowAttributes() ?>>
        <label id="elh_articles_owned" for="x_owned" class="<?= $Page->LeftColumnClass ?>"><?= $Page->owned->caption() ?><?= $Page->owned->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->owned->cellAttributes() ?>>
<span id="el_articles_owned">
<input type="<?= $Page->owned->getInputTextType() ?>" name="x_owned" id="x_owned" data-table="articles" data-field="x_owned" value="<?= $Page->owned->EditValue ?>" size="30" placeholder="<?= HtmlEncode($Page->owned->getPlaceHolder()) ?>" data-format-pattern="<?= HtmlEncode($Page->owned->formatPattern()) ?>"<?= $Page->owned->editAttributes() ?> aria-describedby="x_owned_help">
<?= $Page->owned->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->owned->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->customerId->Visible) { // customerId ?>
    <div id="r_customerId"<?= $Page->customerId->rowAttributes() ?>>
        <label id="elh_articles_customerId" for="x_customerId" class="<?= $Page->LeftColumnClass ?>"><?= $Page->customerId->caption() ?><?= $Page->customerId->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->customerId->cellAttributes() ?>>
<span id="el_articles_customerId">
<input type="<?= $Page->customerId->getInputTextType() ?>" name="x_customerId" id="x_customerId" data-table="articles" data-field="x_customerId" value="<?= $Page->customerId->EditValue ?>" size="30" placeholder="<?= HtmlEncode($Page->customerId->getPlaceHolder()) ?>" data-format-pattern="<?= HtmlEncode($Page->customerId->formatPattern()) ?>"<?= $Page->customerId->editAttributes() ?> aria-describedby="x_customerId_help">
<?= $Page->customerId->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->customerId->getErrorMessage() ?></div>
</span>
</div></div>
    </div>
<?php } ?>
<?php if ($Page->siteId->Visible) { // siteId ?>
    <div id="r_siteId"<?= $Page->siteId->rowAttributes() ?>>
        <label id="elh_articles_siteId" for="x_siteId" class="<?= $Page->LeftColumnClass ?>"><?= $Page->siteId->caption() ?><?= $Page->siteId->Required ? $Language->phrase("FieldRequiredIndicator") : "" ?></label>
        <div class="<?= $Page->RightColumnClass ?>"><div<?= $Page->siteId->cellAttributes() ?>>
<span id="el_articles_siteId">
<input type="<?= $Page->siteId->getInputTextType() ?>" name="x_siteId" id="x_siteId" data-table="articles" data-field="x_siteId" value="<?= $Page->siteId->EditValue ?>" size="30" placeholder="<?= HtmlEncode($Page->siteId->getPlaceHolder()) ?>" data-format-pattern="<?= HtmlEncode($Page->siteId->formatPattern()) ?>"<?= $Page->siteId->editAttributes() ?> aria-describedby="x_siteId_help">
<?= $Page->siteId->getCustomMessage() ?>
<div class="invalid-feedback"><?= $Page->siteId->getErrorMessage() ?></div>
</span>
</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="farticlesadd"><?= $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="farticlesadd" 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("articles");
});
</script>
<script>
loadjs.ready("load", function () {
    // Write your table-specific startup script here, no need to add script tags.
});
</script>
