<div class="mb-3">
    <label for="input-name" class="form-label">
        <?php echo $this->user->lang("Name"); ?>
    </label>
    <input
        type="text"
        class="form-control required"
        id="input-name"
        name="name"
        value="<?php echo $this->name; ?>"
    />
</div>

<div class="mb-3">
    <label for="input-description" class="form-label">
        <?php echo $this->user->lang("Description"); ?>
    </label>
    <textarea
        id="input-description"
        name="description"
        class="form-control"
        rows="4"
    ><?php echo $this->description; ?></textarea>
</div>

<div class="mb-3">
    <label for="input-assignee" class="form-label">
        <?php echo $this->user->lang("Default Assignee"); ?>
    </label>
    <select
        id="input-assignee"
        name="deptid_staffid"
        class="form-select"
    >
        <?php foreach ($this->departments['groups'] as $department) { ?>
            <option
                value="<?php echo $department['assigneeId']; ?>"
                class="<?php echo $department['indentClass']; ?>"
                <?php if ($department['assigneeId'] == $this->selectedDepartment) { ?> selected <?php } ?>
            >
                <?php echo $this->escape($department['assigneeLabel']); ?>
            </option>
        <?php } ?>
    </select>
</div>

<div class="mb-3">
    <label for="customFieldsSelect" class="form-label">
        <?php echo $this->user->lang("Custom Fields"); ?>
    </label>
    <select
        id="customFieldsSelect"
        name="customFields[]"
        multiple
        class="form-select disableSelect2AutoLoad"
    >
        <?php foreach ($this->customFieldsSomeTicketTypes as $customField) { ?>
            <option
                value="<?php echo $customField['id']; ?>"
                <?php if (in_array($customField['id'], $this->selectedCustomfields)) { ?> selected <?php } ?>
            >
                <?php echo $customField['text']; ?>
            </option>
        <?php } ?>
    </select>
</div>

<div class="mb-3">
    <label for="customFieldsAllTicketTypes" class="form-label">
        <?php echo $this->user->lang("Custom Fields for All Ticket Types"); ?>
    </label>
    <select
        id="customFieldsAllTicketTypes"
        name="customFieldsAll[]"
        multiple
        class="form-select disableSelect2AutoLoad"
        disabled
    >
        <?php foreach ($this->customFieldsAllTicketTypes as $customField) { ?>
            <option selected value="<?php echo $customField['id']; ?>">
                <?php echo $customField['text']; ?>
            </option>
        <?php } ?>
    </select>
</div>

<div class="mb-3">
    <div class="form-check">
        <input
            class="form-check-input"
            type="checkbox"
            id="enabled"
            name="enabled"
            <?php if ($this->enabled == 1) { ?> checked <?php } ?>
            <?php if ($this->disableCheckBoxes == true) { ?> disabled checked <?php } ?>
        >
        <label class="form-check-label" for="enabled">
            <?php echo $this->user->lang('Enabled'); ?>
        </label>
    </div>
    <div class="form-check">
        <input
            class="form-check-input"
            type="checkbox"
            id="enabled_public"
            name="enabled_public"
            <?php if ($this->enabledPublic == 1) { ?> checked <?php } ?>
            <?php if ($this->disableCheckBoxes == true) { ?> disabled <?php } ?>
        >
        <label class="form-check-label" for="enabled_public">
            <?php echo $this->user->lang('Enabled in the public section'); ?>
        </label>
    </div>
    <div class="form-check">
        <input
            class="form-check-input"
            type="checkbox"
            id="allowclose"
            name="allowclose"
            <?php if ($this->allowClose == 1) { ?> checked <?php } ?>
        >
        <label class="form-check-label" for="allowclose">
            <?php echo $this->user->lang('Allow client to close tickets'); ?>
        </label>
    </div>
</div>

<input type="hidden" name="id" value="<?php echo $this->id; ?>" />
<input type="hidden" name="systemid" value="<?php echo $this->systemId; ?>" />

<script data-cfasync="false" type="text/javascript">
    $('#customFieldsSelect').select2({
        width: '100%',
        dropdownParent: $(".richwindow"),
        tokenSeparators: [',']
    });

    $('#customFieldsAllTicketTypes').select2({
        width: '100%',
        dropdownParent: $(".richwindow"),
        tokenSeparators: [',']
    });

    $('#input-assignee').select2({
        width: '100%',
        dropdownParent: $(".richwindow")
    });
</script>