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

<input type="hidden" id="inputCustomFieldID" name="customfieldid" />

  <fieldset class="mb-4">
	<div class="mb-3">
	  <label for="inputFieldName" class="form-label">
		<?php echo $this->user->lang('Field Name'); ?>
	  </label>
	  <input type="text" id="inputFieldName" name="customfieldname" class="form-control" value="<?php echo $this->data['customfieldname']; ?>" />
	</div>

	<div class="mb-3">
	  <label for="textareaFieldDescription" class="form-label">
		<?php echo $this->user->lang('Field Description'); ?>
	  </label>
	  <textarea id="textareaFieldDescription" name="customfielddesc" class="form-control"><?php echo $this->data['customfielddesc']; ?></textarea>
	</div>

	<div class="mb-3">
	  <label for="selectFieldType" class="form-label">
		<?php echo $this->user->lang('Field Type'); ?>
	  </label>
		<select id="selectFieldType" name="customfieldtypevalue" class="form-select normalSelect2">
		<?php foreach ($this->customFieldTypeOptions as $option) { ?>
			<option value="<?php echo $option['value']; ?>" <?php if ($option['value'] == $this->data['customfieldtype']) {?>selected="selected"<?php } ?>><?php echo $option['text']; ?></option>
		<?php }?>
	  </select>
	</div>

	<div id="divDropDownOptions" class="mb-3" style="display: none;">
	  <label for="inputDropDownOptions" class="form-label">
		<span class="tip-target" data-bs-html="true" data-bs-toggle="tooltip"
		  title="<?php echo $this->user->lang('Please separate all drop down options by using a comma between each value. To have an option label be different from its value, enter the value between parenthesis'); ?><br /><span class='fst-italic'><?php echo $this->user->lang('eg. red, brown(color_2), yellow'); ?></span>">
		  <?php echo $this->user->lang('Options'); ?>
		</span>
	  </label>
	  <input type="text" id="inputDropDownOptions" name="customfieldoptions" class="form-control" value="<?php echo $this->data['customfieldoptions']; ?>" />
	</div>

	<div class="mb-3">
	  <label for="inputRegex" class="form-label">
		<?php echo $this->user->lang('Regex Validation'); ?>
	  </label>
	  <input type="text" id="inputRegex" name="regex" class="form-control" value="<?php echo $this->data['customfieldregex']; ?>" />
	</div>

	<div class="form-check mb-2">
	  <input type="checkbox" class="form-check-input" id="inputIsRequired" name="customfieldrequired" <?php if ($this->data['customfieldrequired'] == 1) { ?> checked="checked" <?php } ?> />
	  <label for="inputIsRequired" class="form-check-label">
		<?php echo $this->user->lang('Is Required'); ?>
	  </label>
	</div>

	<div class="form-check mb-2">
	  <input type="checkbox" class="form-check-input" id="inputAdminOnly" name="customfieldadminonly" <?php if ($this->data['customfieldadminonly'] == 1) { ?> checked="checked" <?php } ?> />
	  <label for="inputAdminOnly" class="form-check-label">
		<span class="tip-target" data-bs-toggle="tooltip" data-bs-placement="left"
		  title="<?php echo $this->user->lang('This field is only visible by staff members and not visible to the client when viewing their profile.'); ?>">
		  <?php echo $this->user->lang('Admin Only'); ?>
		</span>
	  </label>
	</div>

	<div class="form-check mb-2">
	  <input type="checkbox" class="form-check-input" id="inputEncrypted" name="customfieldencrypted" <?php if ($this->data['customfieldencrypted'] == 1) { ?> checked="checked" <?php } ?> />
	  <label for="inputEncrypted" class="form-check-label">
		<span class="tip-target" data-bs-toggle="tooltip" data-bs-placement="left"
		  title="<?php echo $this->user->lang('This field will be stored encrypted in the database.'); ?>">
		  <?php echo $this->user->lang('Encrypted'); ?>
		</span>
	  </label>
	</div>

	<div class="form-check mb-2">
	  <input type="checkbox" class="form-check-input" id="inputAllTypes" name="globalCustomField" <?php if ($this->data['globalCustomField'] == 1) { ?> checked="checked" <?php } ?> />
	  <label for="inputAllTypes" class="form-check-label">
		<span class="tip-target" data-bs-toggle="tooltip" data-bs-placement="left"
		  title="<?php echo $this->user->lang('This field will be used in all tickets.'); ?>">
		  <?php echo $this->user->lang('All Ticket Types'); ?>
		</span>
	  </label>
	</div>
  </fieldset>

  <fieldset id="fs-tickettypeassociations">
	<legend class="h4 mb-3"><?php echo $this->user->lang('Ticket Types Associated'); ?></legend>
	<div id="divTypesAssociated">
		<?php echo $this->data['associatedList']; ?>
	</div>
  </fieldset>


<script data-cfasync="false">
	$('[data-bs-toggle="tooltip"]').tooltip();

	$('.normalSelect2').select2({
		dropdownParent: $(".richwindow"),
		width: '100%',
	});

	$('#selectFieldType').on('change', function(e) {
		if ($(this).val() == 9) {
			$('#divDropDownOptions').slideDown();
		} else {
			$('#divDropDownOptions').slideUp();
		}
	});

	$('#selectFieldType').trigger('change');
</script>